grails-core: Grails 3.1.0 "Could not resolve view" exceptions when running executible war
Executing the war file after running grails war
or gradlew build
generates the following exception when navigating to the index page in Grails v3.1.0.M1 or v3.1.0.BUILD-SNAPSHOT (39fc3e9c4e99316540afdd4925d9ab3aafcd817a):
java -Dgrails.env=prod -jar build\libs\app310-0.1.war
Grails application running at http://localhost:8080 in environment: production
ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[grailsDispatcherServlet] - Servlet.service() for
servlet [grailsDispatcherServlet] in context with path [] threw exception [Could not resolve view with name '/index' in
servlet with name 'grailsDispatcherServlet'] with root cause
javax.servlet.ServletException: Could not resolve view with name '/index' in servlet with name 'grailsDispatcherServlet'
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1227) ~[spring-webmvc-4.2.1.R
ELEASE.jar!/:4.2.1.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027) ~[spring
-webmvc-4.2.1.RELEASE.jar!/:4.2.1.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971) ~[spring-webmvc-4.2.
1.RELEASE.jar!/:4.2.1.RELEASE]
Full stacktrace is available at https://gist.github.com/jwagenleitner/96928fdb8e342e50c9f6.
The application starts up normally if grails run-app
or grails prod run-app
is executed.
Environments:
Windows 7 64-bit
| Grails Version: 3.1.0.BUILD-SNAPSHOT
| Groovy Version: 2.4.4
| JVM Version: 1.8.0_60
Windows 7 64-bit
| Grails Version: 3.1.0.M1
| Groovy Version: 2.4.4
| JVM Version: 1.8.0_60
To reproduce:
grails create-app app310
cd app310
grails war
orgradlew build
java -Dgrails.env=prod -jar build\libs\app310-0.1.war
- Navigate in browser to
http://localhost:8080/
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 1
- Comments: 19 (7 by maintainers)
Commits related to this issue
- Don't active development environment if standalone deployed. Fixes #9302 — committed to grails/grails-core by graemerocher 8 years ago
You can workaround the issue by doing
cd build/libs
and thenjava -jar app310-0.1.war
Grails gets confused because it thinks you are running the project locally if you run it from the project root.
@rafaeleyng It works for me if I use a
render ""
orreturn true
orreturn false
, else it fails even forgrails run-app
in development mode. I have a simple controller that does nothing but prints some statements that I need for testing. It works well on Grails 2.x.Thanks @jwagenleitner for pointing it out, exactly in the same problem with grails 3.0.7 and tried to solve of my own but couldn’t. Thanks to @graemerocher for providing a workaround, now atleast the app runs , though it has problems with assets compressions but yes, app is running in production mode without that Dispatcher servlet exception related to view . Hoping for a fix soon