I'm running tomcat7 with jdk7 on MacOSX Mavericks DP3. Everything goes well , and it only takes 500 ms to start up . But suddenly, it slows down to 35 seconds.
The log message shows SecureRandom is the root cause. Thanks for google, I found it's a jre bug , and following code to verify:
import java.security.SecureRandom;
class JRand {
public static void main(String args[]) throws Exception {
System.out.println("Ok: " +
SecureRandom.getInstance("SHA1PRNG").nextLong());
}
}
Yes. The simplest code also takes 35 seconds. But it seems that all those related solutions do not work for me. Both /dev/random and /dev/urandom are not block devices on Mac.
cat /dev/random | hexdump -C
output very quickly!
When switched back to jre6, it's very fast to generate randoms. Download the latest jdk8-ea, the problem still exists.
In fact , not only tomcat slows down significantly, Netbeans, glassfish are all affected. After struggling with for hours, I gave up at last.
This morning, when I came to office, plugged in Ethernet, guess what ? It recovered!
So my question is , what happens behind ? It's really weird.
Thanks.
Haha, resolved. Get InetAddress.java source code (can copy from IDE); modify method getLocalHost from
String local = impl.getLocalHostName();
to :
String local = "localhost"; // impl.getLocalHostName();
recompile it, and add java.net.InetAddress.class back to JDK/jre/lib/rt.jar.
RESOLVED.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With