Why does Java Stripe API have Exception NoSuchMethodError for receiveChangeCipherSpec()?

Viewed 171

I am using the Stripe Java library version 5.41.0 on void linux with Payara 5 and OpenJDK [void@void ~]$ java -version openjdk version "1.8.0_202" OpenJDK Runtime Environment (build 1.8.0_202-b00) OpenJDK 64-Bit Server VM (build 25.202-b00, mixed mode)

I am getting an exception for receiveChangeCipherSpec as follows:

java.lang.NoSuchMethodError: sun.security.ssl.Handshaker.receiveChangeCipherSpec()V
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1150)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:347)
    at com.stripe.net.LiveStripeResponseGetter.makeURLConnectionRequest(LiveStripeResponseGetter.java:429)
    at com.stripe.net.LiveStripeResponseGetter.getStripeResponse(LiveStripeResponseGetter.java:582)
    at com.stripe.net.LiveStripeResponseGetter.rawRequest(LiveStripeResponseGetter.java:500)
    at com.stripe.net.LiveStripeResponseGetter.staticRequest(LiveStripeResponseGetter.java:526)
    at com.stripe.net.LiveStripeResponseGetter.request(LiveStripeResponseGetter.java:74)
    at com.stripe.net.APIResource.request(APIResource.java:186)

I thought it might be a lack of the unlimited security policy, but followed the procedure for installing that and I still have the exception as above.

The offending code is this line right now, although no API calls I am doing will work: Customer.retrieve(stripeCustomerId)

Would upgrading the Stripe library fix this, or am I missing a jar from Payara or something?

1 Answers

The answer to this is the same as here (sun.security.ssl.SSLSessionImpl not found). To summarize the problem is that exception NoSuchMethod is really erroneous, it should be more like duplicate classes found, since, to quote Antoine from that question:

Payara/Glassfish embeds native sun.* classes into [glassfish5_home]/glassfish/modules/endorsed/grizzly-npn-bootstrap.jar, so it conflicts with others classes included into [JDK_HOME]/jre/lib/jsse.jar

I used the solution from Antoine, which was to open grizzly-npn-bootstrap.jar and delete the sun folder so that it no longer conflicts and loads the correct classes from jsse.jar.

On linux you can use Ark to open the jar and delete directly, and it appears that on Windows you can do the same thing with 7zip. Make a backup first in case you need to go back to the original jar in the future.

Related