Skip to content

Regression in grails-views 7.0.0-M3 when forwarding from controller #14193

@davidkron

Description

@davidkron

I am currently experimenting with migrating an existing grails application to version 7.0.0-M3. There are some problems related to forwarding requests to other actions/controllers, which result in an error like this:

jakarta.servlet.ServletException: Could not resolve view with name 'route' in servlet with name 'dispatcherServletRegistration'
	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1410)
	at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1167)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1105)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:978)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903)
	at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564)

In this case the action route is called and it is correct that there doesn't exist a route.gsp for this action, because it is simply a dispatcher, that does forward to a different action.

Unfortunately I can't reproduce the error using a simple grails application, so the problem seems to be some special constellation in our application, which is pretty complex.

After some debugging, the problem seems to be that after the forward dispatch (handling of the forwarded request inclusive rendering seems to work as expected), the result handling of the original action will still try to render the view, even though a rendering was already done by the forward. At that point in time, the response is still in a non-committed state, which seems to be the criteria to trigger a render:

I managed to track down the settings of the commited state of the response to catalina's ApplicationDispatcher, where the closing of the response's PrintWriter will commit the response.

PrintWriter writer = response.getWriter();
writer.close();

In version 7.0.0-M3 of grails, the response's print writer seems to be a RoutablePrintWriter from Sitemesh, which doesn't commit anything and seems to be the source of my error. In the previous Grails version, the print writer is a CoyoteWriter, which seems to work as expected.

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions