"/dev/random" hangs in java program when server is inactive

Solution Verified - Updated -

Issue

  • Reading "/dev/random" hangs in java program
  • entropy is too low to generate enough random numbers
  • Java program hangs as it's waiting on a thread that's continuously in this state trying to generate random numbers:

        "main" prio=10 tid=0x00002aab580e2000 nid=0x6c98 runnable [0x000000004044f000]
           java.lang.Thread.State: RUNNABLE
             at java.io.FileInputStream.readBytes(Native Method)
             at java.io.FileInputStream.read(FileInputStream.java:199)
             at sun.security.provider.NativePRNG$RandomIO.readFully(NativePRNG.java:185)
             at sun.security.provider.NativePRNG$RandomIO.implGenerateSeed(NativePRNG.java:202)
             - locked <0x00002aaad23739a0> (a java.lang.Object)
             at sun.security.provider.NativePRNG$RandomIO.access$300(NativePRNG.java:108)
             at sun.security.provider.NativePRNG.engineGenerateSeed(NativePRNG.java:102)
             at java.security.SecureRandom.generateSeed(SecureRandom.java:495)
    

Environment

  • Red Hat Enterprise Linux 5 - All architectures
  • Red Hat Enterprise Linux 6 - All architectures
  • Java application
  • JBoss Enterprise Application Platform (EAP)
  • Tomcat

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.