【问题标题】:Deploy grails 2.5.5 app to tomcat 7将 grails 2.5.5 应用程序部署到 tomcat 7
【发布时间】:2017-09-02 13:23:57
【问题描述】:

我正在尝试将 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,它确实将战争复制到了我的服务器。这次在 /var/lib/tomcat7/webapps/ROOT 中提取实际文件后,我重新启动了 Tomcat,然后给了我上面的日志。当我转到 123.123.123.123:8080 时,我得到一个空白页面,其中包含一个 javascript 错误提示 GET http://123.123.123.123:8080/ 404 (Not Found),我尝试了不同的变体,如 &lt;ip&gt;:8080/myapp&lt;ip&gt;:8080/myapp/home,结果都相同。

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

【问题讨论】:

  • 我不知道那些 Problem with directory 警告是否是导致 找不到此页面的原因,但我通过创建解决了它们像mkdir /usr/share/tomcat7/common/classes 这样的目录。也不要忘记授予权限chown -R tomcat7:tomcat7 /usr/share/tomcat7/common/classes
  • 我猜 webapp 在目录“myapp-0.1”中部署得很好。打开“123.123.123.123:8080/myapp-0.1”会发生什么? “有用!”是来自 apache httpd,而不是来自 tomcat 的默认欢迎页面。
  • 看起来您的项目和/或 grails 已经为 java 8 编译并且您的 Ubuntu 服务器运行 Java 7。stackoverflow.com/questions/22489398/…
  • 不,检查过了。这是我服务器上的内容:java version "1.8.0_144"

标签: tomcat grails web-deployment


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2017-02-27
    • 2015-01-18
    • 1970-01-01
    • 2014-03-04
    • 1970-01-01
    • 2016-09-07
    • 1970-01-01
    • 2017-09-04
    • 2017-04-20
    相关资源
    最近更新 更多