How can I deploy a Grails 3.0.1
war file in, a non-embedded version of, Tomcat7? All I'm getting is a blank page or a 404 error. I can successfully deploy my other war files, so I know it's not a problem with Tomcat. My versions, and the steps I took are below:
Server version: Apache Tomcat/7.0.52 (Ubuntu)
Grails Version: 3.0.1
Groovy Version: 2.4.3
JVM Version: 1.7.0_80
I suspect that the problem has something to do with Spring framework or Gradle. I am not very familiar with either of them, but I did notice that 3.0.1 no longer uses a web.xml
and no longer has a Config.groovy
file. The site below details how to deploy a Grails project in 3.0.x.
http://grails.github.io/grails-doc/3.0.x/guide/deployment.html
- I ran
grails run-app
and it deployed tolocalhost:8080
beautifully with no problems.
I don't want to use the embedded version of Tomcat though. I'd like to deploy it to a different version of Tomcat, and this is where I am running into problems.
- I changed the scope of my Tomcat dependencies to provided:
provided "org.springframework.boot:spring-boot-starter-tomcat"
- I generated the war file using
grails war
- added
website.war
to/var/lib/tomcat7/webapps
- ran
sudo service tomcat7 restart
to restart tomcat - checked to see if
website.war
unpacked automatically (it did) - checked
localhost:9999/website
- added
^ This gives me is a blank white page.
- I deleted
website.war
and it's associated unpacked folder.- checked
localhost:9999
- it successfully brought me to the default Tomcat screen
- signed into manager app
- deployed
website.war
on the manager app - it gave me the
ok
status - checked
localhost:9999/website
- checked
^ This gives me the following error:
HTTP Status 404 - /website, The requested resource is not available.
Other relevant information:
https://grails.github.io/grails-doc/3.0.x/guide/single.html:
"Grails 3.0 no longer requires web.xml. Customizations can be done via Spring"
TheBuildConfig.groovy
file has also been changed.
Old Location:
grails-app/conf/BuildConfig.groovy
New Location:build.gradle
Description: Build time configuration is now defined in a Gradle build file
Other posts I've found: (sorry for not providing links, I cannot post more than two links without at least 10 reputation points.)
grails.org/wiki/Deployment#Tomcat
- This suggests putting a war in the webapps folder. I've already tried that and it's not working.
https://mcmap.net/q/1018655/-grails-app-deploy-in-tomcat-server-using-war-file-fails
- He is asking a very similar question but he is using a different version of Grails
- The marked solution references
Config.groovy
- However build time configuration in
Grails 3.0.1
is now inBuild.gradle
- I don't know if he successfully solved the problem.
https://mcmap.net/q/1018656/-can-39-t-deploy-grails-war-file-in-tomcat-results-in-404
- Solution requires change to
Config.groovy
, which is no longer available inGrails 3.0.1
projects
EDIT:
When it unpacks the website.war
folder the catalina.out
log file shows this:
:: Spring Boot :: (v1.2.3.RELEASE)
Jun 07, 2015 3:01:23 PM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/website]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
at org.apache.tomcat.websocket.server.WsServerContainer.<init>(WsServerContainer.java:147)
at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)
at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5456)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Jun 07, 2015 3:01:23 PM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive /var/lib/tomcat7/webapps/website.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/website]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Jun 07, 2015 3:01:23 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-9999"]
Jun 07, 2015 3:01:23 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 26775 ms
Then, when I try to load localhost:9999/website
the catalina.out
file shows this:
Jun 07, 2015 3:05:04 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-9999"]
Jun 07, 2015 3:05:04 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jun 07, 2015 3:05:04 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-9999"]
Jun 07, 2015 3:05:04 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-9999"]
Jun 07, 2015 3:05:06 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]
Jun 07, 2015 3:05:06 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false]
Jun 07, 2015 3:05:06 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false]
Jun 07, 2015 3:05:06 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false]
Jun 07, 2015 3:05:06 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
Jun 07, 2015 3:05:06 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]
Jun 07, 2015 3:05:06 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-9999"]
Jun 07, 2015 3:05:06 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 576 ms
Jun 07, 2015 3:05:06 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 07, 2015 3:05:06 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.52 (Ubuntu)
Jun 07, 2015 3:05:06 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/host-manager.xml
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/docs.xml
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/manager.xml
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /etc/tomcat7/Catalina/localhost/examples.xml
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Jun 07, 2015 3:05:07 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/website.war
Jun 07, 2015 3:05:07 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat7/webapps/website/WEB-INF/lib/tomcat-embed-core-8.0.20.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Jun 07, 2015 3:05:07 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/var/lib/tomcat7/webapps/website/WEB-INF/lib/tomcat-embed-el-8.0.20.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class
Jun 07, 2015 3:05:07 PM org.apache.catalina.deploy.WebXml setVersion
WARNING: Unknown version string [3.1]. Default version will be used.
catalina.out
file for the Tomcat instance show after you've deployed it through the Web UI or through the copying into thewebapps
folder? – Gradualismcatalina.out
messages after I attempt to deploywebsite.war
by copying it into thewebapps
folder. – Fromm