我想部署一個Grails應用2.5.5到Tomcat 7(Ubuntu的服務器上運行)。我在Intellij 14中使用命令war -stacktrace -verbose
來創建war文件。在我的target
目錄中,它成功創建了戰爭文件,我們稱之爲myapp-0.1.war
。然後在終端(我使用Linux Mint的),我用下面的命令將其複製到我的服務器(我取代的我的個人資料在下面的例子中,像mypcusername
,myserverusername
和123.123.123.123
)部署Grails的2.5.5應用到Tomcat 7
rsync -rtvW --delete /home/mypcusername/NetbeansProjects/myapp/target/myapp-0.1.war/ [email protected]:/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,我通過創建和chowning所有這讓所有那些警告消失目錄跟着他的指示。我正在更新日誌。
由於最初提出的問題,我意識到我從來沒有真正將.war文件複製到我的服務器,因爲當我試圖提取文件時,它會告訴我像「你不能提取目錄」,然後我注意到它每次使用rsync -rtvW --delete /home/mypcusername/NetbeansProjects/myapp/target/myapp-0.1.war/ [email protected]:/home/myserverusername/myapp-0.1.war/
時創建一個名爲myapp-0.1.war的空目錄。
然後我用scp /home/mypcusername/NetBeansProjects/myapp/target/myapp-0.1.war [email protected]:/home/myserverusername
實際上做了戰爭複製到我的服務器。在這次在/ 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
都具有相同的結果不同的變化。
我簽出了this答案,但似乎並不適用於我因爲我的applicationContext.xml中沒有相同的值,該問題的OP有。讓我知道是否需要發佈我的applicationContext.xml。
我不知道如果這些_Problem與directory_警告負責_this頁面無法found_,但我通過創建這些目錄,如'的mkdir/USR /股/ tomcat7 /普通/ classes'等也解決了他們不要忘記授予權限'chown -R tomcat7:tomcat7/usr/share/tomcat7/common/classes'。 – suricatta
我猜想webapp部署得很好,在目錄「myapp-0.1」中。當你打開「123.123.123.123:8080/myapp-0.1」會發生什麼? 「有用!」是來自apache httpd的默認歡迎頁面,而不是來自tomcat。 – andi
看起來像你的項目和/或Grails的已經被編譯爲Java 8和你的Ubuntu服務器runns Java 7中 https://stackoverflow.com/questions/22489398/unsupported-major-minor-version-52-0 – andi