我们需要在 IBM AIX 6.1 中部署一个独立的 jar。这个 jar 尝试使用 hierynomus sshj 和 bouncycastle 连接到 SFTP 服务器。当尝试实例化 KeyAgreement 时,在执行时,它会输出以下内容:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:172)
at java.security.Provider$Service$1.run(Provider.java:831)
at java.security.Provider$Service$1.run(Provider.java:823)
at java.security.AccessController.doPrivileged(AccessController.java:202)
at java.security.Provider$Service.newInstance(Provider.java:821)
at java.security.SecureRandom.<init>(SecureRandom.java:114)
at javax.crypto.b.<clinit>(Unknown Source)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at javax.crypto.KeyAgreement.getInstance(Unknown Source)
at net.schmizz.sshj.common.SecurityUtils.registerSecurityProvider(SecurityUtils.java:88)
at net.schmizz.sshj.common.SecurityUtils.register(SecurityUtils.java:267)
at net.schmizz.sshj.common.SecurityUtils.isBouncyCastleRegistered(SecurityUtils.java:245)
at net.schmizz.sshj.DefaultConfig.<init>(DefaultConfig.java:78)
at net.schmizz.sshj.SSHClient.<init>(SSHClient.java:135)
at com.dxc.seat.eai.EailSftpClient.getConnection(EailSftpClient.java:312)
at com.dxc.seat.eai.EailSftpClient.startProcess(EailSftpClient.java:200)
at com.dxc.seat.eai.SFTPFileInput.main(SFTPFileInput.java:17)
Caused by: java.lang.NullPointerException
at org.bouncycastle.jcajce.provider.drbg.DRBG$NonceAndIV.engineGenerateSeed(Unknown Source)
at java.security.SecureRandom.generateSeed(SecureRandom.java:343)
at org.bouncycastle.jcajce.provider.drbg.DRBG$HybridSecureRandom.<init>(Unknown Source)
at org.bouncycastle.jcajce.provider.drbg.DRBG.createBaseRandom(Unknown Source)
at org.bouncycastle.jcajce.provider.drbg.DRBG.access$200(Unknown Source)
at org.bouncycastle.jcajce.provider.drbg.DRBG$Default.<clinit>(Unknown Source)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
... 19 more
用来运行这个 jar 的 JVM 是:
java version "1.6.0"
Java(TM) SE Runtime Environment (build pap6460sr9fp1ifix-20110511(SR9 P1+IZ97552))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc64-64 jvmap6460sr9-20110203_74623 (JIT enabled, AOT enabled)
J9VM - 20110203_074623
JIT - r9_20101028_17488ifx3
GC - 20101027_AA)
JCL - 20110203_01
通过将新的安全提供程序附加到 java.security 提供程序列表的末尾并将库: bcpkix-jdk15on-1.60.jar bcprov-jdk15on-1.60.jar 添加到 ext 目录,已更新 JVM 安全设置。
独立 jar 是使用 maven-assembly-plugin 构建的。
我们想知道为什么会发生这种情况以及我们如何解决它。