I am upgrading a project from Spring 3 to Spring 6 using XML based DI.
I have a TranslatingViewResolver that extends AbstractCachingViewResolver. Here is a debug telling how this is operating...
.TranslatingViewResolver 100159440 | Translating:postpone.noValidDate to forward:/webapp/message?heading=postpone.message.statusError.heading&message=postpone.message.noValidDate
(That is an InternalResourceView, btw.)
And then the next message is an exception:
2025-06-16 13:00:34,207 105827 WARN org.springframework.web.servlet.PageNotFound 100159440 | No mapping for GET /fed1/webapp/forward:/webapp/message
org.springframework.web.servlet.NoHandlerFoundException: No endpoint GET /fed1/webapp/forward:/webapp/message.
Can't figure out what mangled the forward to have path in front of it.
I have a UrlBasedViewResolver, which i think I read I need for resolving the forwards. I have a debug in log4j2.xml like:
<Logger name="org.springframework.web.servlet.view.UrlBasedViewResolver" level="DEBUG">
<AppenderRef ref="MyFile"/>
<AppenderRef ref="Console"/>
</Logger>
But am not seeing anything in the log.
I've been researching forward:
and it seems like I have everything configured correctly, plus it worked in the previous version.
Out of things to try and could use some help.
UPDATE
Looking at the stack trace:
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) ~[spring-webmvc-6.2.7.jar:6.2.7]
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:710) ~[servlet-api.jar:6.1]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:130) ~[catalina.jar:11.0.8]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-websocket.jar:11.0.8]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:109) ~[catalina.jar:11.0.8]
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:514) ~[catalina.jar:11.0.8]
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:334) ~[catalina.jar:11.0.8]
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:263) ~[catalina.jar:11.0.8]
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:171) ~[spring-webmvc-6.2.7.jar:6.2.7]
As indicated above, InternalResourceView has the correct URL. When it comes back to FrameworkServlet it is mangled. I can't seem to step through the code inside of tomcat.
This makes no sense. It's starting to look like a bug in either tomcat or Spring.
UPDATE 2
It's beginning to look like this issue is because of a double forward. My code gets forwarded to the PostponeController that has a look at it and says nothing to do here and forwards to the message controller, only it never makes it there because of the error.
When pulling the information from the request for the forward, it's pulling the path info for the postpone and that's where the prefix is coming from. This is inside tomcat 11's ApplicationHttpRequest.getRequestDispatcher()
.
I'm not sure how this is really supposed to work, since it just worked before, but I'm digging in. Appreciate any insights.
UPDATE 3
So, I believe forward:
to be a spring framework thing and not part of the servlet engine (please correct if wrong). As such we have no business passing that to tomcat. Nevertheless, that's what happening here.
Inside of InternalResourceView.renderMergedOutputModel
, it has this line of code:
RequestDispatcher rd = getRequestDispatcher(request, dispatcherPath);
Where the dispatcherPath
contains the forward:. This looks like a Spring Framework bug to me.
Turns out it is not a bug. As I now understand, I could simply return the /message
without the forward:
prefix. The forward is only so the UrlBasedViewResolver would handle the resolution.
The fact that this worked in previous versions is partly what led me to believe this was a bug.