1

Springboot occassionally occur following errors:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.security.jca.ProviderConfig$ProviderLoader

at java.base/sun.security.jca.ProviderConfig$3.run(ProviderConfig.java:244)

at java.base/sun.security.jca.ProviderConfig$3.run(ProviderConfig.java:238)

at java.base/java.security.AccessController.doPrivileged(Native Method)

at java.base/sun.security.jca.ProviderConfig.doLoadProvider(ProviderConfig.java:238)

at java.base/sun.security.jca.ProviderConfig.getProvider(ProviderConfig.java:218)

at java.base/sun.security.jca.ProviderList.getProvider(ProviderList.java:266)

at java.base/sun.security.jca.ProviderList$ServiceList.tryGet(ProviderList.java:511)

at java.base/sun.security.jca.ProviderList$ServiceList$1.hasNext(ProviderList.java:565)

at java.base/javax.crypto.SecretKeyFactory.nextSpi(SecretKeyFactory.java:301)

at java.base/javax.crypto.SecretKeyFactory.<init>(SecretKeyFactory.java:121)

at java.base/javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:168)

at com.kingbase8.shaded.com.ongres.scram.common.ScramMechanisms.saltedPassword(ScramMechanisms.java:155)

at com.kingbase8.shaded.com.ongres.scram.common.ScramFunctions.saltedPassword(ScramFunctions.java:59)

at com.kingbase8.shaded.com.ongres.scram.client.ScramSession$ClientFinalProcessor.<init>(ScramSession.java:196)

at com.kingbase8.shaded.com.ongres.scram.client.ScramSession$ClientFinalProcessor.<init>(ScramSession.java:163)

at com.kingbase8.shaded.com.ongres.scram.client.ScramSession$ServerFirstProcessor.clientFinalProcessor(ScramSession.java:130)

JDK information as following:

enter image description here

James Yang
  • 11
  • 2
  • Note. The source code line who throws the exception is https://github.com/openjdk/jdk11u/blob/jdk-11+28/src/java.base/share/classes/sun/security/jca/ProviderConfig.java#L244 – Happy Dec 20 '21 at 08:11

3 Answers3

0

Ah, please try to search the log, it is possible a ExceptionInInitializerError was happened before, so this time the JVM throws NoClassDefFoundError directly because it was failed last time.

Need to get the call stack of the original ExceptionInInitializerError (if it exists) in order to fix this issue.

Related codes and links

Happy
  • 757
  • 9
  • 18
  • I add configruation -Djava.security.debug="jca" in server start script and not found ExceptionInInitializerError log. how to fixing this error? – James Yang Dec 24 '21 at 08:20
0

For this problem not very clear why occur. in order to fix the problem. we can manual use Security.addSecurity method to load jca or analogous component again. like BouncyCastle. now it work fine for me.

James Yang
  • 11
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 29 '21 at 06:04
0

I was using Java 11 and the project was build using Java 1.8. Once I switched to Java 1.8 it worked fine

likeGreen
  • 1,001
  • 1
  • 20
  • 40