Tomcat7 在部署应用程序时挂起

Tomcat7 在部署应用程序时挂起

我在 Ubuntu 14.04 上的 Tomcat 7 中遇到了一些非常奇怪的行为。

我创建了一个新的 VPS,安装了 default-jdk 和其他一些简单的东西。下载并解压了 Tomcat 7。检查它是否可以在 上运行[myIP]:8080,并查看了 Tomcat 的索引页。

重启 VPS 后,我再次启动了 Tomcat,结果……没有任何反应[myIP]:8080。甚至没有错误。当我检查日志时,我发现 Tomcat 在第一个 webapp 上处于部署状态。

我的日志

Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/7.0.57
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Nov 3 2014 08:39:16 UTC
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         7.0.57.0
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Linux
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            3.13.0-37-generic
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JAVA_HOME:             /usr/lib/jvm/java-7-openjdk-amd64/jre
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.7.0_65-b32
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         /opt/tomcat
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         /opt/tomcat
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/opt/tomcat/endorsed
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/opt/tomcat
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/opt/tomcat
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.io.tmpdir=/opt/tomcat/temp
Dec 31, 2014 9:06:04 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
Dec 31, 2014 9:06:04 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Dec 31, 2014 9:06:04 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2327 ms
Dec 31, 2014 9:06:04 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 31, 2014 9:06:04 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.57
Dec 31, 2014 9:06:04 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat/webapps/host-manager
Dec 31, 2014 9:11:09 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [303,104] milliseconds.
Dec 31, 2014 9:11:09 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /opt/tomcat/webapps/host-manager has finished in 304,682 ms
Dec 31, 2014 9:11:09 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat/webapps/manager
Dec 31, 2014 9:11:09 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /opt/tomcat/webapps/manager has finished in 271 ms
Dec 31, 2014 9:11:09 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat/webapps/docs
Dec 31, 2014 9:11:09 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /opt/tomcat/webapps/docs has finished in 205 ms
Dec 31, 2014 9:11:09 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat/webapps/examples
Dec 31, 2014 9:11:11 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /opt/tomcat/webapps/examples has finished in 1,422 ms
Dec 31, 2014 9:11:11 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat/webapps/ROOT
Dec 31, 2014 9:11:11 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory /opt/tomcat/webapps/ROOT has finished in 177 ms
Dec 31, 2014 9:11:11 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Dec 31, 2014 9:11:11 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Dec 31, 2014 9:11:11 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 306957 ms
Dec 31, 2014 9:17:35 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Dec 31, 2014 9:17:35 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Dec 31, 2014 9:17:35 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Dec 31, 2014 9:17:36 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Dec 31, 2014 9:17:36 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Dec 31, 2014 9:17:36 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Dec 31, 2014 9:17:36 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/7.0.57
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Nov 3 2014 08:39:16 UTC
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         7.0.57.0
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Linux
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            3.13.0-37-generic
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JAVA_HOME:             /usr/lib/jvm/java-7-openjdk-amd64/jre
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.7.0_65-b32
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         /opt/tomcat
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         /opt/tomcat
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/opt/tomcat/endorsed
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/opt/tomcat
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/opt/tomcat
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.io.tmpdir=/opt/tomcat/temp
Dec 31, 2014 9:20:01 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
Dec 31, 2014 9:20:01 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Dec 31, 2014 9:20:01 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Dec 31, 2014 9:20:01 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1536 ms
Dec 31, 2014 9:20:02 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 31, 2014 9:20:02 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.57
Dec 31, 2014 9:20:02 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat/webapps/host-manager
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/7.0.57
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Nov 3 2014 08:39:16 UTC
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         7.0.57.0
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Linux
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            3.13.0-37-generic
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JAVA_HOME:             /usr/lib/jvm/java-7-openjdk-amd64/jre
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.7.0_65-b32
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         /opt/tomcat
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         /opt/tomcat
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=/opt/tomcat/endorsed
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=/opt/tomcat
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=/opt/tomcat
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.io.tmpdir=/opt/tomcat/temp
Dec 31, 2014 9:33:38 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
Dec 31, 2014 9:33:38 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Dec 31, 2014 9:33:38 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Dec 31, 2014 9:33:38 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2495 ms
Dec 31, 2014 9:33:39 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 31, 2014 9:33:39 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.57
Dec 31, 2014 9:33:39 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat/webapps/host-manager

直到第 74 行,服务器启动都很正常。所有标准 Web 应用程序都已部署(第 48-68 行),但之后就挂起了。因此,我停止了服务器并重新启动了系统。再次启动 tomcat,奇迹就开始了。下一个会话位于第 89-136 行,您可以看到那里没有 的条目Server startup in xxxx ms

它只是在部署时挂起,这种情况一直在重复。这可能是什么原因造成的?我花了几个小时来解决这个问题,我快要疯了,却一无所获。

答案1

一个可能的问题是 Tomcat 正在等待熵的积累。查看几个线程转储以jstack查看谁在等待什么。

Tomcat 7+ 严重依赖SecureRandom类为其会话 ID 和其他内容提供随机值。根据您的 JRE,如果用于初始化的熵源熵SecureRandom不足,则可能会导致启动期间延迟。

如果问题出在熵上,那么可以通过设置以下系统属性来配置 JRE 以使用非阻塞熵源:

-Djava.security.egd=file:/dev/./urandom

有关详细信息,请参阅相关讨论

答案2

可能对某些人有帮助:

检查你的 pom.xml 中没有这样的依赖项:

    <dependency>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-catalina</artifactId>
        <version>8.0.23</version>
    </dependency>

答案3

导致该问题的可能原因是:密钥库文件路径输入错误:

keystoreFile="conf/cert/certificate.ks"

相关内容