6

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

2 Answers 2

15

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.

4
  • 1
    You, sir, are my savior.
    – Etki
    May 24, 2016 at 12:20
  • Hi, I'm having the same issue on MacOS Catalina and I was trying the option above but it didn't work for me. Do you have any other solutions which may work in my case? Regards
    – vchar
    Apr 26, 2020 at 22:47
  • The suggested solution does not work for me inside my VM. But what i noticed is that this only occurs when doing a 'service tomcat stop' or 'service tomcat start'. Using 'service tomcat restart' (whatever the current status is) makes this problem go away. The terminal is now not freezing anymore.
    – Tim B.
    Jun 14, 2020 at 22:59
  • The link is broken but I found similar howto with lots of information: community.denodo.com/kb/view/document/… I face this trouble on Azure. Jun 18, 2020 at 14:40
3

That problem happens when you use virtual machines. Set Djava.security.egd=file:/dev/./urandomns in the file setenv.sh

3
  • this bit of information is important, I have a VM with that problem and it solved it
    – kiltek
    Jul 4, 2017 at 9:41
  • 1
    Your copy&paste went wrong. It is missing the - in -Djava.security.egd, and it is urandom instead of urandomns.
    – toolforger
    Jan 18, 2020 at 10:27
  • Also, an answer should explain why it works.
    – toolforger
    Jan 18, 2020 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.