-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloudfoundry specific actuators should not be affected if server.context-path is changed #9081
Comments
It turned out too be quite a big change for 1.5.4. We can revisit this in 2.0 |
It would be really nice to support context path in 1.5.X. Upgrading to 2.0 may be a challenge for larger organizations, especially those that haven't made the move to Java 8 yet. Are there any workarounds for the folks on 1.5 until this is revisited? |
@zmb3 For 1.5.3, the workaround is to add a new context that can handle requests to "/cloudfoundryapplication" and forward them to the original context. Here's the example for tomcat. @Bean
public TomcatEmbeddedServletContainerFactory servletContainerFactory() {
return new TomcatEmbeddedServletContainerFactory() {
@Override
protected void prepareContext(Host host,
ServletContextInitializer[] initializers) {
super.prepareContext(host, initializers);
StandardContext child = new StandardContext();
child.addLifecycleListener(new Tomcat.FixContextListener());
child.setPath("/cloudfoundryapplication");
ServletContainerInitializer initializer = getServletContextInitializer(getContextPath());
child.addServletContainerInitializer(initializer, Collections.emptySet());
child.setCrossContext(true);
host.addChild(child);
}
};
}
private ServletContainerInitializer getServletContextInitializer(String contextPath) {
return (c, context) -> {
Servlet servlet = new GenericServlet() {
@Override
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
ServletContext context = req.getServletContext().getContext(contextPath);
context.getRequestDispatcher("/cloudfoundryapplication").forward(req, res);
}
};
context.addServlet("cloudfoundry", servlet).addMapping("/*");
};
} |
As an alternative, is there a way to tell cloudfoundry the correct path for the |
@mbhave I tried your suggestion using Spring Boot 1.5.4 , but I am recieving a null pointer exception. Am i missing something?
|
@toplac Are you sure you're using Spring Boot 1.5.4? It uses Tomcat 8.5.15 by default but your stack trace indicates that you're using 8.5.11. |
@wilkinsona Thanks for the hint. There was an indeed an error in my pom.xml. I have fixed the dependency issue, but i still get the same error:
|
@toplac That |
@wilkinsona I have applied the suggestion from #9081 (comment) EDIT: We solved it using zuul in combination using "forward" Here is an example:
|
We're going to document this as a known limitation. |
Is there a similar solution to this problem when using the newly introduced |
@mcordeiro73 can you open a new issue for that one please? |
New issue created for Reactive based applications #24991 |
is this issue resolved? iam using spring boot 2.6.1 and getting the same error am using undertow, can anyone share a workaround for it, thanks |
@sathish593 This is documented as a known limitation. There would be some undertow-specific configuration similar to Tomcat. Can you open a new issue so that we can look into documenting it for Undertow and Jetty as well? |
No description provided.
The text was updated successfully, but these errors were encountered: