无法初始化类 javax.crypto.SunJCE_b
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20994797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not initialize class javax.crypto.SunJCE_b
提问by AJF
I have a Java servlet application developed and on my develpment PC everything works as expected including using SFTP programmatically to copy over a PDF using HTTPS on port 8443 etc and with SSL certificates in place too.
我开发了一个 Java servlet 应用程序,在我的开发 PC 上,一切都按预期工作,包括以编程方式使用 SFTP 在端口 8443 等上使用 HTTPS 复制 PDF,并使用 SSL 证书。
However, when I attempt to run the application on the Live server I receive the error;
但是,当我尝试在 Live 服务器上运行该应用程序时,我收到错误消息;
java.lang.NoClassDefFoundError: Could not initialize class javax.crypto.SunJCE_b
java.lang.NoClassDefFoundError: 无法初始化类 javax.crypto.SunJCE_b
On investigation, some are suggesting check the jce.jar. But I have ensured the jce.jar is present and also created a "lib" folder in my project and copied the jar there and placed the jar on my build path but still the problem exists.
在调查中,有些人建议检查 jce.jar。但是我已经确保 jce.jar 存在并且还在我的项目中创建了一个“lib”文件夹并将 jar 复制到那里并将 jar 放在我的构建路径上,但问题仍然存在。
How do I resolve this please? Thanks in advance. Here is the console output from right after Tomcat has started the application;
请问我该如何解决?提前致谢。这是 Tomcat 启动应用程序后的控制台输出;
#08-Jan-2014 10:45:44 org.apache.catalina.startup.Catalina start
INFO: Server startup in 12715 ms
08-Jan-2014 10:47:42 org.apache.tomcat.util.net.NioEndpoint$SocketProcessor run
SEVERE:
java.lang.NoClassDefFoundError: Could not initialize class javax.crypto.SunJCE_b
at javax.crypto.Cipher.getInstance(DashoA13*..)
at com.sun.net.ssl.internal.ssl.JsseJce.getCipher(Unknown Source)
at com.sun.net.ssl.internal.ssl.RSAClientKeyExchange.<init>(Unknown Source)
at com.sun.net.ssl.internal.ssl.ServerHandshaker.processMessage(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.net.ssl.internal.ssl.Handshaker$DelegatedTask.run(Unknown Source)
at org.apache.tomcat.util.net.SecureNioChannel.tasks(SecureNioChannel.java:285)
at org.apache.tomcat.util.net.SecureNioChannel.handshakeUnwrap
(SecureNioChannel.java:343)
at org.apache.tomcat.util.net.SecureNioChannel.handshake
(SecureNioChannel.java:193)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run
(NioEndpoint.java:1642)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
采纳答案by Toni Toni Chopper
The jce.jar
must be inside the folder WEB-INF/lib
of the deployed web application.
在jce.jar
必须在文件夹中WEB-INF/lib
已部署的Web应用程序。
回答by Charlie
I've seen this problem pop up very often and there seems to be a lot of confusion around it. The actual reason this is happening is because the JRE you are using to run your application has been set up with the unrestricted JCE policy jars inside its jre/lib folder (inside your jdk install folder).
我经常看到这个问题出现,而且似乎有很多困惑。发生这种情况的实际原因是,您用来运行应用程序的 JRE 已在其 jre/lib 文件夹(在您的 jdk 安装文件夹内)中设置了不受限制的 JCE 策略 jar。
If your current project does not need these, then you can move then out of this folder temporarily. This will remove the requirement on the jce libraries and you will no longer see this error.
如果您当前的项目不需要这些,那么您可以暂时移出此文件夹。这将消除对 jce 库的要求,您将不再看到此错误。
Hope this helps.
希望这可以帮助。