为什么 Java Stripe API 对于 receiveChangeCipherSpec() 有异常 NoSuchMethodError?

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

我在 void linux 上使用带 Payara 5 和 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)

的 Stripe Java 库版本 5.41.0

我收到 receiveChangeCipherSpec 的异常如下:

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)

我以为可能是缺少无限制的安全策略,但按照步骤安装,还是出​​现上述异常。

现在有问题的代码是这一行,尽管我正在做的 API 调用都不起作用:Customer.retrieve(stripeCustomerId)

升级 Stripe 库会解决这个问题,还是我缺少 Payara 的 jar 或其他东西?

这个问题的答案和这里一样()。总结一下这个问题是异常 NoSuchMethod 确实是错误的,它应该更像是 duplicate classes found,因为,从那个问题中引用 Antoine:

帕亚拉/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

我使用了 Antoine 的解决方案,即打开 grizzly-npn-bootstrap.jar 并删除 sun 文件夹,使其不再冲突并从 [=14= 加载正确的 类 ].

在linux上可以用方舟打开jar直接删除,在Windows上好像可以用7zip做同样的事情。先做个备份,以防以后需要回到原来的jar。