I'm new to GRAILS but I built a simple app and I'm trying to deploy it to tomcat.
If I run the app using:
grails prod run-app
everything works fine. However, if I build it to a war file
grails prod war
then either upload the war package to a tomcat server or run it directly like
java -Dgrails.env=prod -jar build\lib\app.war
then I get this strange behaviour where everything seems fine at first but whenever I click on a link for an action other than index, I get a 404 error. Eg
webapp:8080/employee WORKS
webapp:8080/employee/index WORKS
webapp:8080/employee/show/1 404 error
webapp:8080/department WORKS
webapp:8080/department/show/1 404 error
etc.
In the above example webapp:8080/employee/show/1 should definitely be found because it is listed and linked from a table in the index.
Im having a huge amount of trouble getting to the bottom of it because I cant seem to find any feedback from a running war file whether I run it in tomcat or directly, even if I move environments to test or dev. Theres just nothing in the log files or stdout.
Here is my UrlMappings
package generico
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.$format)?"{
constraints {
// apply constraints here
}
}
// "/"(view:"/index")
"/"(controller:"employee", action:"index")
"500"(view:'/error')
"404"(view:'/notFound')
}
}
Again, everything works absolutely fine if I do "grails run-app" for any environment.
I appreciate any help. Thanks.
I'm having the same problem with Grails 3.2.2.
Can't get "/" to load. I'm using namespaces so my mapping looks like
"/"(namespace: 'corp', controller: 'index', action: 'index')
with
com.example.corp.IndexController {
static namespace = 'corp'
def index() {)
}
Everything works correctly in any environment with grails run-app but when I war and run it gives me an error page.
My problem was with Grails 3.2.1. After I updated to Grails 3.2.2, did a gradle clean, then repackaged, everything works fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.