Ubuntu14 Tomcat7 Application deployment time

July 18, 2014 2.4k views

I am noticing that deploying a new applicaiton on tomcat7 takes a while to deploy. In the logs i can see all is clear but i cannot connect to http://host:8080 . Browser just hangs.....

[localhost-startStop-1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 12833 ms

Any ideas why i cannot connect ? If i wait half an hour, perhaps i will be able to connect...

2 comments
  • Ok, so after waiting for about 2 hours, i can connect with the application now ...

    If i restart tomcat7, it takes similar time to access the app.

  • Refer http://wiki.apache.org/tomcat/HowTo/FasterStartUp

    Entropy Source

    Tomcat 7+ heavily relies on SecureRandom class to provide random values for its session ids and in other places. Depending on your JRE it can cause delays during startup if entropy source that is used to initialize SecureRandom is short of entropy. You will see warning in the logs when this happens, e.g.:

    <DATE> org.apache.catalina.util.SessionIdGenerator createSecureRandom
    INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [5172] milliseconds.
    There is a way to configure JRE to use a non-blocking entropy source by setting the following system property: -Djava.security.egd=file:/dev/./urandom

    Note the "/./" characters in the value. They are needed to work around known Oracle JRE bug #6202721.

    Also note that replacing the blocking entropy source (/dev/random)

2 Answers

I ran into the same thing and it took forever to figure out.

Problem

The random number generator collects various bits of information from the operation of the system as an "entropy source" to provide more randomness. This process blocks the start of the Tomcat server.

Solution

Use a different source of random numbers.

In /etc/default/tomcat7, add the following line below the existing JAVA_OPTS variable.

JAVA_OPTS="${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom"
Have another answer? Share your knowledge.