在linux 或者 Solaris下如果碰到类似下面的异常信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
java.security.ProviderException: nextBytes() failed at sun.security.provider.NativePRNG$RandomIO.implNextBytes(NativePRNG.java:270) at sun.security.provider.NativePRNG$RandomIO.access$200(NativePRNG.java:108) at sun.security.provider.NativePRNG.engineNextBytes(NativePRNG.java:97) at java.security.SecureRandom.nextBytes(SecureRandom.java:433) at java.util.UUID.randomUUID(UUID.java:162) . . . . . . . . . . .省略 Caused by: java.io.EOFException: /dev/[u]random closed? at sun.security.provider.NativePRNG$RandomIO.readFully(NativePRNG.java:187) at sun.security.provider.NativePRNG$RandomIO.ensureBufferValid(NativePRNG.java:247) at sun.security.provider.NativePRNG$RandomIO.implNextBytes(NativePRNG.java:261) ... 44 more |
这是由于 随机数读取报错引起的,一般的解决办法有以下三种:
[1]、尝试删除随机数设备的连接,再重新绑定
1 2 3 4 5 6 |
bash-2.03# rm -f *random bash-2.03# ln -s ../devices/pseudo/random@0:random random bash-2.03# ln -s ../devices/pseudo/random@0:urandom urandom bash-2.03# ls -Fl *random lrwxrwxrwx 1 root other 33 Sep 9 12:03 random -> ../devices/pseudo/random@0:random lrwxrwxrwx 1 root other 33 Sep 9 12:03 urandom -> ../devices/pseudo/random@0:random |
[2]、Java 启动参数的修改
-Djava.security.egd=file:/dev/./urandom
tips:注意红色字体部分。
[3]、java.security文件配置修改
打开%JDVA_HOME%/jre/lib/security/java.security 文件,找到如下内容:
securerandom.source=file:/dev/urandom
修改成:
securerandom.source=file:/dev/./urandom
tips:注意红色字体部分。
原创文章,转载请注明: 转载自micmiu – 软件开发+生活点滴[ http://www.micmiu.com/ ]
我想问一下你的code部分是用 的什么插件么?
用的SyntaxHighlighter Evolved