我正在尝试启动一个 tomcat webapp,但在测试服务器(下载 vanilla tomcat8)时,它似乎在启动时挂起了。我猜是它挂在了处理 SecureRandom 类的某个东西上。我听说 tomcat 有时会在生成熵时停滞。
以下是我的版本:
Java
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
雄猫
8.0.15
Ubuntu
VERSION="14.04.1 LTS, Trusty Tahr"
当我尝试启动它时,它似乎挂起了部署主机管理器 Web 应用的进程。这是我等待大约 5 分钟后的日志
willkara@SkyHold:/opt$ more /opt/tomcat8/logs/catalina.out
09-Jan-2015 14:42:50.085 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.15
09-Jan-2015 14:42:50.087 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Nov 2 2014 19:25:20 UTC
09-Jan-2015 14:42:50.088 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.15.0
09-Jan-2015 14:42:50.088 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
09-Jan-2015 14:42:50.088 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.13.0-37-generic
09-Jan-2015 14:42:50.089 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
09-Jan-2015 14:42:50.089 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JAVA_HOME: /usr/lib/jvm/java-7-openjdk-amd64/jre
09-Jan-2015 14:42:50.089 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.7.0_65-b32
09-Jan-2015 14:42:50.090 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
09-Jan-2015 14:42:50.090 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /home/willkara/tomcat8
09-Jan-2015 14:42:50.090 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /home/willkara/tomcat8
09-Jan-2015 14:42:50.091 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/opt/tomcat8/conf/logging.properties
09-Jan-2015 14:42:50.092 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
09-Jan-2015 14:42:50.092 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=/opt/tomcat8/endorsed
09-Jan-2015 14:42:50.093 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/opt/tomcat8
09-Jan-2015 14:42:50.093 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/opt/tomcat8
09-Jan-2015 14:42:50.093 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/opt/tomcat8/temp
09-Jan-2015 14:42:50.094 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.libr
ary.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
09-Jan-2015 14:42:50.257 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
09-Jan-2015 14:42:50.293 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
09-Jan-2015 14:42:50.297 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
09-Jan-2015 14:42:50.299 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
09-Jan-2015 14:42:50.300 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1026 ms
09-Jan-2015 14:42:50.334 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
09-Jan-2015 14:42:50.334 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.15
09-Jan-2015 14:42:50.347 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /home/willkara/tomcat8/webapps/host-manager
我还附加了几个不同的 jstack 转储来查看 Java VM 是否一切正常。
答案1
看起来这肯定是 SecureRandom 类的熵生成存在问题。
我将此标志添加到 JAVA_OPTS:-Djava.security.egd=file:/dev/./urandom 并且它启动得非常正常。
我知道这不是解决问题的完美方法,所以我想看看升级到 Java8 是否可以解决问题。
我从以下来源获取信息此链接。
答案2
使用虚拟机时会发生该问题。在文件 setenv.sh 中设置 Djava.security.egd=file:/dev/./urandomns