我正在尝试将Grails 2.5.5应用程序部署到Tomcat 7(在Ubuntu服务器上运行)。我在Intellij 14中使用了war -stacktrace -verbose命令来创建war文件。在我的target目录中,它成功创建了war文件,我们将其称为myapp-0.1.war。然后在终端(我正在使用Linux Mint)中,我使用以下命令将其复制到服务器上(在下面的示例中,我的详细信息替换为mypcusernamemyserverusername123.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/

也不必担心上述命令的NetbeansProjects部分,它最初是一个Netbeans项目。然后,我先使用sudo cp -a myapp-0.1.war/ /var/lib/tomcat7/webapps/,再使用sudo rm -R ROOT删除原始的ROOT目录。然后我运行了sudo service tomcat7 restart,这就是问题所在。日志给了我以下内容:
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

编辑,由于suricatta,我按照他的指示创建并整理了所有使所有这些警告都消失的目录。我正在更新日志。

自从最初提出这个问题以来,我意识到我从未真正将.war文件复制到我的服务器,因为当我尝试提取文件时,它会告诉我诸如“您无法提取目录”之类的内容,然后我注意到它创建了一个每次我使用rsync -rtvW --delete /home/mypcusername/NetbeansProjects/myapp/target/myapp-0.1.war/ myserverusername@123.123.123.123:/home/myserverusername/myapp-0.1.war/时,都会创建一个名为myapp-0.1.war的空目录。

然后,我使用了scp /home/mypcusername/NetBeansProjects/myapp/target/myapp-0.1.war myserverusername@41.185.91.194:/home/myserverusername,它确实将 war 复制到了我的服务器上。这次在/ var / lib / tomcat7 / webapps / ROOT中提取了实际文件后,我重新启动了Tomcat,然后得到了上面的日志。当我转到123.123.123.123:8080时,出现空白页面,并显示javascript错误,显示GET http://123.123.123.123:8080/ 404 (Not Found),并尝试了不同的变体,例如<ip>:8080/myapp<ip>:8080/myapp/home,均得到了相同的结果。

我 checkout 了this答案,但这似乎不适用于我,因为我的applicationContext.xml中的值与该问题的OP没有相同。让我知道是否需要发布我的applicationContext.xml。

最佳答案

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

10-07 13:20
查看更多