Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java cryptography library sporadically fails to start

We have a Java web application that sporadically fails to find cryptographic libraries. Currently restarting the application fixes the issue.

The following expections appear in the logs, see below for full stack trace.

java.lang.InternalError: Could not start up the CDSA libraries.
java.lang.NoClassDefFoundError: Could not initialize class com.apple.crypto.provider.HmacMD5

The application is built using Java 1.6.0_15 and is deployed to 1.6.0_13 running on Mac OS X Server 10.5.8 (9L30)

Any ideas ?

Cheers

Jono

Build Java version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode)

Deployed Jave version
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03-226)
Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02-92, mixed mode)

Full stack trace:

java.lang.NoClassDefFoundError: Could not initialize class com.apple.crypto.provider.HmacMD5
       at java.lang.ClassLoader$NativeLibrary.load(Native Method)
       at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1881)
       at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1782)
       at java.lang.Runtime.loadLibrary0(Runtime.java:823)
       at java.lang.System.loadLibrary(System.java:1047)
       at com.apple.crypto.provider.HmacCore.<clinit>(HmacCore.java:26)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
       at java.lang.Class.newInstance0(Class.java:355)
       at java.lang.Class.newInstance(Class.java:308)
       at java.security.Provider$Service.newInstance(Provider.java:1221)
       at javax.crypto.Mac.a(DashoA13*..)
       at javax.crypto.Mac.init(DashoA13*..)
       at com.sun.net.ssl.internal.ssl.MAC.<init>(MAC.java:94)
       at com.sun.net.ssl.internal.ssl.CipherSuite$MacAlg.newMac(CipherSuite.java:429)
       at com.sun.net.ssl.internal.ssl.Handshaker.newWriteMAC(Handshaker.java:407)
       at com.sun.net.ssl.internal.ssl.SSLSocketImpl.changeWriteCiphers(SSLSocketImpl.java:1791)
       at com.sun.net.ssl.internal.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:607)
       at com.sun.net.ssl.internal.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:868)
       at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:794)
       at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:226)
       at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
       at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
       at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
       at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
       at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
       at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
       at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
       at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
       at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:506)
       at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
       at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
       at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
       at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
       at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
       at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
like image 354
Jonoabroad Avatar asked Nov 15 '22 14:11

Jonoabroad


1 Answers

Your error doesn't mean the class is not found. "Could not initialize class com.apple.crypto.provider.HmacMD5" means that the static intizializer block (static { ... }) caused an exception. Do you have access to the source code of MmacMD5?

We once had a similar problem where the static block failed due to a non-reachable X server - but only if no X-forwarding-enabled SSH session to the server was available. (The class was registering fonts to later use them for rendering images)

like image 75
sfussenegger Avatar answered Dec 23 '22 09:12

sfussenegger