简体   繁体   English

Java 8 32位-无法初始化JCE

[英]Java 8 32-bit - Could not initialize JCE

I update project JDK to jdk1.8.144_32bit (from 1.7). 我将项目JDK更新为jdk1.8.144_32bit(从1.7开始)。

But the following error occurs: 但是会发生以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class javax.crypto.JceSecurity
    at javax.crypto.SecretKeyFactory.nextSpi(SecretKeyFactory.java:295)
    at javax.crypto.SecretKeyFactory.<init>(SecretKeyFactory.java:121)
    at javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:160)
    at oracle.jdbc.driver.T4C8TTIdty.<init>(T4C8TTIdty.java:517)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1603)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:496)
    at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:666)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:566)
    at org.apache.commons.dbcp2.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:53)
    at org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:279)
    at org.apache.commons.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2343)
    at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2329)
    at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2071)
    at org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1525)

Then I installed JCE from Oracle download site: https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html 然后我从Oracle下载站点安装了JCE: https : //www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

Nothing change except I'm quite sure that JCE is installed according to such answers: https://stackoverflow.com/a/13238132 除了我非常确定已根据以下答案安装了JCE之外,没有任何更改: https : //stackoverflow.com/a/13238132

In my scenario: 在我的情况下:

System.out.println(Cipher.getMaxAllowedKeyLength("AES"));

return 返回

2147483647

What's wrong? 怎么了? Why this environment doesn't work correctly? 为什么此环境无法正常工作?

I'm working with jdk1.8.144 in 32bit version. 我正在使用32位版本的jdk1.8.144。 And Eclipse Oxygen.3a Release (4.7.3a) 和Eclipse Oxygen.3a版本(4.7.3a)

I found an answer. 我找到了答案。 It wasn't problem with neither JDK nor Eclipse. JDK和Eclipse都没有问题。 Simple answer is: 简单的答案是:

In our code there is java.home variable assigned to custom value. 在我们的代码中,有java.home变量分配给自定义值。

Explanation: 说明:

Variable java.home points to Java installation directory as said in documentation of System.getProperties() . System.getProperties()文档中所述,变量java.home指向Java安装目录。 It is always available. 它始终可用。 In normal scenario value of this variable is inferred from JAVA_HOME system variable. 在正常情况下,此变量的值是从JAVA_HOME系统变量推断出来的。

More interesting reading here on SO . 关于SO的更多有趣的阅读。

But because of some strange configuration of our computers somebody made a decision to set it manually for local test environment. 但是由于我们计算机的配置有些奇怪,因此有人决定手动为本地测试环境设置它。 And it worked until JDK migration when JDK path has changed. 它一直有效,直到JDK迁移(当JDK路径已更改)。

Hints for others: 其他提示:

After JDK upgrade when you are using Eclipse there are several places to check configuration: 在使用Eclipse进行JDK升级之后,可以在几个地方检查配置:

  1. Preferences -> Java -> Installed JRE 首选项-> Java->已安装的JRE
  2. Project properties -> Java Build Path -> JRE System Library 项目属性-> Java构建路径-> JRE系统库
  3. Project properties -> Java Compiler 项目属性-> Java编译器
  4. Run Configuration (for example for Maven build run) -> JRE 运行配置(例如,用于Maven构建运行)-> JRE
  5. Check System.getenv() variables if any has strange value. 检查System.getenv()变量是否有奇怪的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM