Tomcat 8 hangs on startup while deploying webapp. Possibly related to entropy generation
I'm trying to get a tomcat webapp started and while just testing out the server (vanilla tomcat8 download) it seems to be hanging on startup. My guess is that it is hung up on something dealing with the SecureRandom class. I heard that tomcat can sometimes stall while generating entropy.
Here are my versions:
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)
Tomcat
8.0.15
Ubuntu
VERSION="14.04.1 LTS, Trusty Tahr"
When I try and start it up, it seems to hang deploying the host-manager webapp. This is my log after about 5 minutes of waiting
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
I've also attached a few different jstack dumps to see if everything is okedoke with the java VM.
Dump 1
Dump 2
Solution 1:
Looks like it definitely was a problem with entropy generation with the SecureRandom class.
I added this flag to the JAVA_OPTS: -Djava.security.egd=file:/dev/./urandom and it starts up perfectly fine.
I know this isn't the perfect way to fix the problem so I'm going to see if upgrading to Java8 may solve it.
I got my information from this link.
Solution 2:
That problem happens when you use virtual machines. Set Djava.security.egd=file:/dev/./urandomns in the file setenv.sh