2016-01-22 139 views
0

我使用Tomcat Manager進行部署。無論何時我修改網站並編譯一個新的.WAR(稱爲home.war)並進行部署,當我加載根URL時,我會收到一個404錯誤Tomcat WAR部署會創建一個404

正確配置,http://schmud.de應加載http://schmud.de/home/

關鍵事實:如果我重新啓動Tomcat實例,則部署將正常工作。我該如何避免這種情況?這裏是server.xml<host>配置:

<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="false"> 

    <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> 

    <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> 

    <!-- Access log processes all example. 
      Documentation at: /docs/config/valve.html 
      Note: The pattern used is equivalent to using pattern="common" --> 

    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
      prefix="localhost_access" suffix=".log" rotatable="false" 
      pattern="%h %l %u %t &quot;%r&quot; %s %b" /> 

    <Context path="" docBase="home" debug="0" reloadable="true" /> 

</Host> 

我在Apache Tomcat/7.0.42,JVM 1.7.0,Linux的2.6.32。這是一個cPanel機器。

編輯:經過長時間的延遲,我在本地重建了Tomcat機器,因此我可以完全訪問所有參數。這裏是我的日誌顯示錯誤,當我取消部署,然後重新部署相同的應用程序,導致404錯誤:

tomcat7/localhost.2016-02-14.log,取消部署和重新部署 -

Feb 14, 2016 1:04:59 PM org.apache.catalina.core.ApplicationContext log 
INFO: HTMLManager: undeploy: Undeploying web application at '/home' 
Feb 14, 2016 1:05:00 PM org.apache.catalina.core.ApplicationContext log 
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost' 
Feb 14, 2016 1:06:44 PM org.apache.catalina.core.ApplicationContext log 
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost' 

tomcat7/catalina.2016-02-14.log從取消部署重新部署 -

Feb 14, 2016 1:05:00 PM org.apache.catalina.startup.HostConfig undeploy 
INFO: Undeploying context [/home] 
Feb 14, 2016 1:05:03 PM org.apache.catalina.loader.WebappClassLoader modified 
SEVERE:  Resource '/WEB-INF/lib/args4j-2.0.26.jar' is missing 
Feb 14, 2016 1:05:03 PM org.apache.catalina.core.StandardContext reload 
INFO: Reloading Context with name [] has started 
Feb 14, 2016 1:05:03 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 
SEVERE: The web application [] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. 
Feb 14, 2016 1:05:03 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 
SEVERE: The web application [] appears to have started a thread named [New I/O worker #1] but has failed to stop it. This is very likely to create a memory leak. 
Feb 14, 2016 1:05:03 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks 
SEVERE: The web application [] created a ThreadLocal with key of type [com.ning.http.client.providers.netty.NettyAsyncHttpProvider.ThreadLocalBoolean] (value [com.ning.http.c[email protected]288f896e]) and a value of type [java.lang.Boolean] (value [false]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 
Feb 14, 2016 1:05:03 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks 
SEVERE: The web application [] created a ThreadLocal with key of type [org.jboss.netty.util.CharsetUtil$1] (value [[email protected]]) and a value of type [java.util.IdentityHashMap] (value [{[email protected]}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 
Feb 14, 2016 1:05:03 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks 
SEVERE: The web application [] created a ThreadLocal with key of type [com.ning.http.client.providers.netty.NettyAsyncHttpProvider.ThreadLocalBoolean] (value [com.ning.http.c[email protected]288f896e]) and a value of type [java.lang.Boolean] (value [true]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 
Feb 14, 2016 1:05:03 PM org.apache.catalina.core.StandardContext resourcesStart 
SEVERE: Error starting static Resources 
java.lang.IllegalArgumentException: Document base /var/lib/tomcat7/webapps/home does not exist or is not a readable directory 
    at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:136) 
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:5089) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3988) 
    at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:425) 
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1345) 
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530) 
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540) 
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540) 
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519) 
    at java.lang.Thread.run(Thread.java:745) 

Feb 14, 2016 1:05:03 PM org.apache.catalina.core.StandardContext reload 
SEVERE: Exception starting Context with name [] 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) 
    at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3988) 
    at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:425) 
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1345) 
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530) 
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540) 
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540) 
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: org.apache.catalina.LifecycleException: Error in resourceStart() 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5270) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    ... 8 more 

Feb 14, 2016 1:05:03 PM org.apache.catalina.core.StandardContext reload 
INFO: Reloading Context with name [] is completed 
Feb 14, 2016 1:06:20 PM org.apache.catalina.startup.HostConfig deployWAR 
INFO: Deploying web application archive /var/lib/tomcat7/webapps/home.war 

上面清楚地說明了這些錯誤,但我對Tomcat的理解並不夠熟悉。

+1

你的webapps/look怎麼樣?在部署之前,您是否刪除了ROOT.war?你有沒有檢查你的日誌重新部署時會發生什麼? – Jan

+0

@Jan - ROOT.war被刪除。經過長時間的延遲,我已經添加了上面的日誌。顯然有一個錯誤。我不知道該怎麼做。 –

回答

0

當你說你重新啓動服務器,你的意思是tomcat實例或框本身?根據我的經驗部署新版本時,應該重新啓動Tomcat實例。編寫一個部署腳本來節省時間會更有益處。

+0

我的意思是重新啓動Tomcat實例。重新啓動Tomcat的問題是我沒有權限執行此操作。即使更新是微不足道的,我也必須提出管理請求。我希望避免這種情況。 –

+0

您必須重新啓動tomcat實例才能使更改生效。 – aemorales1

+0

這是令人失望的。我希望更好地理解爲什麼用相同的.war重新部署一個.war會導致這種情況。 –