apache / apache/grails-core

Running a war file doesn't work if it has a path

Open
#12,173 4 comments 0 reactions 0 assignees View on GitHub
info: example-attached
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

Just wasted a few days of my life trying to figure out why a war file won't run....

This doesn't work...

`java -Dgrails.env=development -jar build/libs/myapp.war
`

If you do it, grails won't be able to find your view files.

This will work...

`(cd build/libs ; java -Dgrails.env=development -jar myapp.war )
`

This really should work as expected... however at the very least, if it can't support the correct behavior, it should exit gracefully with a meanful error message rather than starting up tomcat, but misbehaving.

This issue seems to have come up before, but it didn't seem as if people understood that the problem is related to having a path on the command line:

https://github.com/grails/grails-core/issues/605

and I'm not the first one to be confused about what is wrong:

https://stackoverflow.com/questions/37863465/how-to-run-grails-3-1-x-application-with-java

Here is some stack trace from when it fails...

```
2021-11-09 17:29:57.687 ERROR --- [nio-8083-exec-2] .a.c.c.C.[.[.[.[grailsDispatcherServlet] : Servlet.service() for servlet [grailsDispatcherServlet] in context with path [/living-collection] threw exception [Could not resolve view with name 'search' in servlet with name 'grailsDispatcherServlet'] with root cause
javax.servlet.ServletException: Could not resolve view with name 'search' in servlet with name 'grailsDispatcherServlet'
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1352)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
```

grails 4.0.12

Contributor guide

Open the contributing guide

Research direction

Start with the build/libs/myapp.war launch command and the grailsDispatcherServlet view-resolution failure described in the report; compare it with the working command run from inside build/libs. Review the related issue 605 for context. Done means a WAR launched with a path behaves correctly, or exits with a meaningful error instead of starting Tomcat and failing to resolve views.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, java, spring
Domain
backend, build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.