【问题标题】:Tomcat WAR deployment creates a 404Tomcat WAR 部署创建 404
【发布时间】:2016-01-22 16:01:42
【问题描述】:

我使用 Tomcat Manager 进行部署。每当我更改网站并编译一个新的.WAR(称为home.war)并部署它时,当我加载我的根 URL 时会收到 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.client.providers.netty.NettyAsyncHttpProvider$ThreadLocalBoolean@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 [org.jboss.netty.util.CharsetUtil$1@6e49414c]) and a value of type [java.util.IdentityHashMap] (value [{US-ASCII=sun.nio.cs.US_ASCII$Encoder@6e14afdd}]) 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.client.providers.netty.NettyAsyncHttpProvider$ThreadLocalBoolean@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 的了解还不够,无法理解它们。

【问题讨论】:

  • 你的 webapps/ 看起来如何?您在部署之前是否删除了 ROOT.war?你检查过你的日志吗?重新部署时会发生什么?
  • @Jan - ROOT.war 已删除。经过长时间的延迟,我添加了上面的日志。显然有错误。我不知道该怎么办。

标签: java apache tomcat tomcat7


【解决方案1】:

当您说您重新启动服务器时,您是指 tomcat 实例还是盒子本身?根据我的经验,在部署新版本时应该重启 Tomcat 实例。编写部署脚本以节省时间会更有益。

【讨论】:

  • 我的意思是重启 Tomcat 实例。重新启动 Tomcat 的问题是我没有这样做的权限。即使更新是微不足道的,我也必须提出管理员请求。我希望避免这种情况。
  • 您必须重启 tomcat 实例才能使您的更改生效。
  • 这令人失望。我很想更好地理解为什么用完全相同的 .war 重新部署一个 .war 会导致这种情况。
  • 好吧,服务器一直在运行,所以它已经有应用程序在运行,我能想到的最好的办法是它以某种方式被缓存了。现在有一个记录在案的方法可以实现这一点,但我的团队无法让它发挥作用,我们的项目管理人员也没有时间来解决这个问题,因为重新启动服务器几乎没有时间去做。如果更改没有生效,这也会增加维护的混乱;我强烈建议您坚持重启,以确保您知道更改已在其中,但如果您想将此通知您的中间件团队,他们可能会这样做
猜你喜欢
  • 2018-03-13
  • 2017-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-05
  • 2015-05-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多