Why is startup so slow after switching to Java 8 / Tomcat 8?

2017-06-07
After upgradig an existing system to Java 8 / Tomcat 8, you notice that the time it takes from a restart to serving QueueMetrics may run into a few minutes. While this happens, Java appears to be using almost no CPU and just be idling. What is going on?

The default settings for Java 8 is to use a strong source of randomness as a seed to generate random numbers that are cryptographically secure. Unfortunately, in order to do this, it has to wait for sufficient entropy to build up, and this may take a long time (even minutes).

As you will not likely need to use such a high level of randomness in QM, but you will prefer quick boot times for the application, you can easily edit the file /etc/sysconfig/qm-tomcat6 and change the line that says: JAVA_OPTS="-server -Dtomcat.instance=$TOMCAT_INSTANCE $JAVA_MEM $JAVA_RMI" To: JAVA_OPTS="-server -Djava.security.egd=file:/dev/./urandom -Dtomcat.instance=$TOMCAT_INSTANCE $JAVA_MEM $JAVA_RMI" Then restart with service queuemetrics restart. Now it should start up in a few seconds.

This setting is already in place for new installs, so this procedure is only needed on systems that were originally installed using Java 6.