简体   繁体   中英

Deploy grails 2.5.5 app to tomcat 7

I'm trying to deploy a Grails 2.5.5 app to Tomcat 7 (running on Ubuntu server). I used the command war -stacktrace -verbose in Intellij 14 to create the war file. Inside my target directory it successfully created the war file, let's call it myapp-0.1.war . Then in the terminal (I'm using Linux Mint) I used the following command to copy it to my server (I substitued my details in the example below, like mypcusername , myserverusername and 123.123.123.123 )

rsync -rtvW --delete /home/mypcusername/NetbeansProjects/myapp/target/myapp-0.1.war/ myserverusername@123.123.123.123:/home/myserverusername/myapp-0.1.war/

Don't worry about the NetbeansProjects part of the above command either, it was originally a Netbeans project. Then I used sudo cp -a myapp-0.1.war/ /var/lib/tomcat7/webapps/ followed by sudo rm -R ROOT to delete the original ROOT directory. Then I ran sudo service tomcat7 restart and this is where the problem is. The logs gave me the following:

Sep 03, 2017 10:23:39 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Sep 03, 2017 10:23:39 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Sep 03, 2017 10:23:39 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Sep 03, 2017 10:23:39 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Sep 03, 2017 10:23:43 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Sep 03, 2017 10:23:43 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1734 ms
Sep 03, 2017 10:23:43 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 03, 2017 10:23:43 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.52 (Ubuntu)
Sep 03, 2017 10:23:43 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
Sep 03, 2017 10:24:18 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined
Sep 03, 2017 10:24:18 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
2017-09-03 10:24:26,325 [localhost-startStop-1] ERROR context.ContextLoader  - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [CacheGrailsPlugin]!
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [CacheGrailsPlugin]!
    ... 5 more
Caused by: java.lang.UnsupportedClassVersionError: grails/plugin/cache/CacheConfigArtefactHandler : Unsupported major.minor version 52.0 (unable to load class grails.plugin.cache.CacheConfigArtefactHandler)
    at CacheGrailsPlugin.<init>(CacheGrailsPlugin.groovy:49)
    ... 5 more
2017-09-03 10:24:26,330 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener  - Error initializing the application: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [CacheGrailsPlugin]!
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [CacheGrailsPlugin]!
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [CacheGrailsPlugin]!
    ... 5 more
Caused by: java.lang.UnsupportedClassVersionError: grails/plugin/cache/CacheConfigArtefactHandler : Unsupported major.minor version 52.0 (unable to load class grails.plugin.cache.CacheConfigArtefactHandler)
    at CacheGrailsPlugin.<init>(CacheGrailsPlugin.groovy:49)
    ... 5 more
2017-09-03 10:24:26,332 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener  - Error initializing Grails: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [CacheGrailsPlugin]!
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [CacheGrailsPlugin]!
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.codehaus.groovy.grails.exceptions.NewInstanceCreationException: Could not create a new instance of class [CacheGrailsPlugin]!
    ... 5 more
Caused by: java.lang.UnsupportedClassVersionError: grails/plugin/cache/CacheConfigArtefactHandler : Unsupported major.minor version 52.0 (unable to load class grails.plugin.cache.CacheConfigArtefactHandler)
    at CacheGrailsPlugin.<init>(CacheGrailsPlugin.groovy:49)
    ... 5 more
Sep 03, 2017 10:24:26 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Sep 03, 2017 10:24:26 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors
Sep 03, 2017 10:24:26 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Sep 03, 2017 10:24:26 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 43228 ms

EDIT Thanks to suricatta, I followed his instructions by creating and chowning all the directories which made all those warnings go away. I'm updating the logs.

Since originally asking the question I realised that I never actually copied a .war file to my server because when I tried to extract the files it would tell me something like "you can't extract a directory", I then noticed that it created an empty directory called myapp-0.1.war every time I used rsync -rtvW --delete /home/mypcusername/NetbeansProjects/myapp/target/myapp-0.1.war/ myserverusername@123.123.123.123:/home/myserverusername/myapp-0.1.war/ .

I then used scp /home/mypcusername/NetBeansProjects/myapp/target/myapp-0.1.war myserverusername@41.185.91.194:/home/myserverusername which did actually copy the war to my server. After extracting the actual files this time in /var/lib/tomcat7/webapps/ROOT I restarted Tomcat and that then gave me the above logs. When I go to 123.123.123.123:8080 I get a blank page with a javascript error saying GET http://123.123.123.123:8080/ 404 (Not Found) and I tried different variations like <ip>:8080/myapp and <ip>:8080/myapp/home all with the same result.

I checked out this answer but that doesn't seem to apply to me coz I don't have the same values in my applicationContext.xml that the OP of that question has. Let my know if I need to post my applicationContext.xml.

我开始了一个新项目,将我要部署的项目中的所有内容复制到新项目中并进行了部署,这解决了我遇到的问题。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM