Skip to content

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

@xpusostomos

Description

@xpusostomos

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:

#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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions