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://stackoverflow.com/a/23664531/104993)

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)

Community
  • 1
  • 1
Kirby
  • 1,980
  • 3
  • 21
  • 33
  • Check your 'webapps' folder in your tomcat installation. Maybe you have a context path issue. E.g. when your server url is 'http://123.com/' and your war was named 'ROOT.war', then it will be deployed at 'webapps/ROOT' and online at 'http://123.com/'. But when it was named 'myapp.war' it will be deployed in the 'webapps/myapp' folder and online with context path: 'http://123.com/myapp'. – Mexx Jan 20 '17 at 09:22
  • yea, the war is named myapp-0.1.war ... and it seems to be deploying to the correct folder under webapps/myapp-0.1/ https://foo.com:8443/myapp-0.1/ is what the tomcat manager links to.. and it gives a 404. :( Thank you, though. – Kirby Jan 20 '17 at 15:28

1 Answers1

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

Jimi D
  • 547
  • 4
  • 9
  • 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. – Kirby Jan 20 '17 at 17:06
  • 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. – Mexx Jan 24 '17 at 09:09
  • You're right. It's a weird behavior, but I put them back in and it worked. I've edited my answer. – Jimi D Jan 24 '17 at 19:04