davidkron opened a new issue, #738:
URL: https://github.com/apache/grails-views/issues/738
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:
https://github.com/apache/grails-core/blob/c4012113edc8bc7ad86e2158f7942790c56d68c2/grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java#L371
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]