4

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?

Halcyon
  • 1,376
  • 1
  • 15
  • 22
  • 1
    `sun.security.ssl.Handshaker` Oracle purchased Sun in 2009. The classes in "sun.security" were still present in Java 1.7; but they're gone in 1.8. Upgrade Stripe to a version that supports Java 8. – Elliott Frisch Jan 15 '19 at 00:20
  • @ElliottFrisch: `sun.security.ssl` is in all j7-11; you may be thinking of the change from j5-6 where they were `com.sun.net.ssl.internal` – dave_thompson_085 Jan 15 '19 at 10:19

1 Answers1

1

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.

Halcyon
  • 1,376
  • 1
  • 15
  • 22
  • That makes sense; I had started to look at the source and there were definitely recent changes to these classes, including adding method `receiveChangeCipherSpec`, although I'm not good enough at mercurial to pin down exactly when. If your Payara jar contained a not-totally-up-to-date copy you would get this exception. – dave_thompson_085 Jan 15 '19 at 10:22