404 when deploying Grails 3.1.10 war to tomcat7 or tomcat8
Asked Answered
F

1

1

The closest stackoverflow question that explains my symptoms is here - How can I deploy a Grails 3.0.1 war file in Tomcat7?

I am in the process of upgrading a Grails 2.3.4 application to Grails 3.1.10 and everything is working with 'grails run-app'.

When i deploy to a war i get nothing but 404's for any url.

The war deploys without any error messages in catalina.out.

The tomcat access logs show my access attempts. (not linux problem?)

I can get to the tomcat manager, and the tomcat manager shows my app as "running" as true. (no errors)

Manager shows myapp-0.1 because the war file was myapp-0.1.war .. this is fine for now.

I am running Grails 3.1.10.

I have tried against Tomcat 7.0.55 as well as 8.0.92.

I have tried changing grails.serverUrl in application.groovy to various values. It is now:

//fix war name after get working
grails.serverUrl = "/myapp-0.1"
System.setProperty("server.contextPath","/myapp-0.1")

I have tried the above without "-0.1". (i was suprised to learn this was necessary - https://mcmap.net/q/1018656/-can-39-t-deploy-grails-war-file-in-tomcat-results-in-404)

I have tried changing "org.springframework.boo:spring-boot-starter-tomcat" from "compile" to "provided" in the build.gradle file.

Please let me know what I need to elaborate on. It's difficult to paste log outputs and config files. (i'm behind a firewall)

Fugere answered 19/1, 2017 at 22:8 Comment(2)
Check your 'webapps' folder in your tomcat installation. Maybe you have a context path issue. E.g. when your server url is '123.com' and your war was named 'ROOT.war', then it will be deployed at 'webapps/ROOT' and online at '123.com'. But when it was named 'myapp.war' it will be deployed in the 'webapps/myapp' folder and online with context path: '123.com/myapp'.Trophoblast
yea, the war is named myapp-0.1.war ... and it seems to be deploying to the correct folder under webapps/myapp-0.1/ foo.com:8443/myapp-0.1 is what the tomcat manager links to.. and it gives a 404. :( Thank you, though.Fugere
N
1

You add the following task to your build.gradle it will name the war what ever you want:

task wrapper(type:Wrapper){
     war.archiveName='myWar.war'
}

Then when you deploy it should have the correct name and you can go to https://localhost:8080/myWar

Natch answered 20/1, 2017 at 16:59 Comment(3)
It's terrifying to think that a Grails 3 generated (grails create-app) build.gradle would contain a build.config that wouldn't build to war out of the box. This got me forward, but i'd love to know why. This also solved my war name problem too! Thank you.Fugere
In my grails apps I did not remove the mentioned lines and it perfectly deploys. Seems to be a strange behaviour, maybe it depends on the used tomcat version. No problem with tomcat 8.5.9 in my case.Trophoblast
You're right. It's a weird behavior, but I put them back in and it worked. I've edited my answer.Natch

© 2022 - 2024 — McMap. All rights reserved.