When I try to use okhttp
or javax.ws.rs.client.Client
the following error occur
java.lang.NoSuchMethodError: sun.security.
The changes in the security ciphers in java 1.8.0_161 have broken the SSL function in the underlying Grizzly server of Glassfish 5,0. The last working java version was 1.8.0_152 As of the moment of this writing i can confirm, that java 1.8.0_202 works with Glassfish 5.1 (now maintained by and downloadable from Eclipse.org) The included grizzly-npn-bootstrap is ver 1.9.0. There is no need to delete or alter anything.
The issue appears because 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
So edit the grizzly-npn-bootstrap.jar
(make a copy before) file and remove the sun folder.
The above Error could result to this displaying in your browser:
The connection was reset The connection to the server was reset while the page was loading. The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer’s network connection. If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
SOLUTION Download: http://central.maven.org/maven2/org/glassfish/grizzly/grizzly-npn-bootstrap/1.8.1/grizzly-npn-bootstrap-1.8.1.jar and Replace your galssfish/payara grizzly-npn-bootstrap.jar.
mv grizzly-npn-bootstrap-1.8.1.jar glassfish5/glassfish/modules/endorsed/grizzly-npn-bootstrap.jar
I just came across this frustrating issue and I did want to expand just a little on Antoine's answer above https://stackoverflow.com/a/52479362/4722577 which worked for me.
As a note, I have Glassfish 5.0 and Java openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
As mentioned by Antoine, I copied the grizzly-npn-bootstrap.jar
to another location as a backup.
I did the jar -xvf grizzly-npn-bootstrap.jar
to see the exact classes and folder locations in the jar. Which gave me the following output:
cduran@cduran-VirtualBox:~/Documents$ jar -xvf grizzly-npn-bootstrap.jar
inflated: META-INF/MANIFEST.MF
created: META-INF/
created: META-INF/maven/
created: META-INF/maven/org.glassfish.grizzly/
created: META-INF/maven/org.glassfish.grizzly/grizzly-npn-bootstrap/
inflated: META-INF/maven/org.glassfish.grizzly/grizzly-npn-bootstrap/pom.properties
inflated: META-INF/maven/org.glassfish.grizzly/grizzly-npn-bootstrap/pom.xml
created: org/
created: org/glassfish/
created: org/glassfish/grizzly/
created: org/glassfish/grizzly/npn/
inflated: org/glassfish/grizzly/npn/AlpnClientNegotiator.class
inflated: org/glassfish/grizzly/npn/AlpnServerNegotiator.class
inflated: org/glassfish/grizzly/npn/ClientSideNegotiator.class
inflated: org/glassfish/grizzly/npn/NegotiationSupport.class
inflated: org/glassfish/grizzly/npn/ServerSideNegotiator.class
created: sun/
created: sun/security/
created: sun/security/ssl/
inflated: sun/security/ssl/Alerts.class
inflated: sun/security/ssl/AlpnExtension$Builder.class
inflated: sun/security/ssl/AlpnExtension.class
inflated: sun/security/ssl/ClientHandshaker$1.class
inflated: sun/security/ssl/ClientHandshaker$2.class
inflated: sun/security/ssl/ClientHandshaker.class
inflated: sun/security/ssl/ExtensionType.class
inflated: sun/security/ssl/GrizzlyNPN.class
inflated: sun/security/ssl/HandshakeMessage$1.class
inflated: sun/security/ssl/HandshakeMessage$CertificateMsg.class
inflated: sun/security/ssl/HandshakeMessage$CertificateRequest.class
inflated: sun/security/ssl/HandshakeMessage$CertificateVerify$1.class
inflated: sun/security/ssl/HandshakeMessage$CertificateVerify.class
inflated: sun/security/ssl/HandshakeMessage$ClientHello.class
inflated: sun/security/ssl/HandshakeMessage$DH_ServerKeyExchange.class
inflated: sun/security/ssl/HandshakeMessage$DistinguishedName.class
inflated: sun/security/ssl/HandshakeMessage$ECDH_ServerKeyExchange.class
inflated: sun/security/ssl/HandshakeMessage$Finished.class
inflated: sun/security/ssl/HandshakeMessage$HelloRequest.class
inflated: sun/security/ssl/HandshakeMessage$NextProtocol$Builder.class
inflated: sun/security/ssl/HandshakeMessage$NextProtocol.class
inflated: sun/security/ssl/HandshakeMessage$RSA_ServerKeyExchange.class
inflated: sun/security/ssl/HandshakeMessage$ServerHello.class
inflated: sun/security/ssl/HandshakeMessage$ServerHelloDone.class
inflated: sun/security/ssl/HandshakeMessage$ServerKeyExchange.class
inflated: sun/security/ssl/HandshakeMessage.class
inflated: sun/security/ssl/Handshaker$1.class
inflated: sun/security/ssl/Handshaker$DelegatedTask.class
inflated: sun/security/ssl/Handshaker.class
inflated: sun/security/ssl/HelloExtensions.class
inflated: sun/security/ssl/NextProtocolNegotiationExtension$Builder.class
inflated: sun/security/ssl/NextProtocolNegotiationExtension.class
inflated: sun/security/ssl/SSLEngineImpl.class
inflated: sun/security/ssl/ServerHandshaker$1.class
inflated: sun/security/ssl/ServerHandshaker$2.class
inflated: sun/security/ssl/ServerHandshaker$3.class
inflated: sun/security/ssl/ServerHandshaker.class
sun
folder.grizzly-npn-bootstrap.jar
by just adding the META-INF and org folders: jar -cvf grizzly-npn-bootstrap.jar META-INF/* org/*
jar -xvf grizzly-npn-bootstrap.jar
command I get this output (notice no more sun folder listed):cduran@cduran-VirtualBox:~/glassfish-5.0-web-profile/glassfish5/glassfish/modules/endorsed$ jar -xvf grizzly-npn-bootstrap.jar
created: META-INF/
inflated: META-INF/MANIFEST.MF
created: META-INF/maven/
created: META-INF/maven/org.glassfish.grizzly/
created: META-INF/maven/org.glassfish.grizzly/grizzly-npn-bootstrap/
inflated: META-INF/maven/org.glassfish.grizzly/grizzly-npn-bootstrap/pom.properties
inflated: META-INF/maven/org.glassfish.grizzly/grizzly-npn-bootstrap/pom.xml
created: org/glassfish/
created: org/glassfish/grizzly/
created: org/glassfish/grizzly/npn/
inflated: org/glassfish/grizzly/npn/ClientSideNegotiator.class
inflated: org/glassfish/grizzly/npn/ServerSideNegotiator.class
inflated: org/glassfish/grizzly/npn/AlpnClientNegotiator.class
inflated: org/glassfish/grizzly/npn/NegotiationSupport.class
inflated: org/glassfish/grizzly/npn/AlpnServerNegotiator.class
After this I no longer get that error message the OP posted above:
java.lang.NoSuchMethodError: sun.security.ssl.SSLSessionImpl.(Lsun/security/ssl/ProtocolVersion;Lsun/security/ssl/CipherSuite;Ljava/util/Collection;Lsun/security/ssl/SessionId;Ljava/lang/String;I)V
Maybe a little bit more elegant is to use the existing fix done in the npn-grizzly jar:
mkdir -p scratch/glassfish5/glassfish/modules/endorsed && cd scratch
wget http://download.oracle.com/glassfish/5.0.1/nightly/glassfish-5.0.1-b02-12_03_2018.zip
wget http://central.maven.org/maven2/org/glassfish/grizzly/grizzly-npn-bootstrap/1.8.1/grizzly-npn-bootstrap-1.8.1.jar
mv grizzly-npn-bootstrap-1.8.1.jar glassfish5/glassfish/modules/endorsed/grizzly-npn-bootstrap.jar
jar uvf glassfish-5.0.1-b02-12_03_2018.zip glassfish5/glassfish/modules/endorsed/grizzly-npn-bootstrap.jar
echo "you have a patched archive for runnig with Java 8 patchlevel 191"
HTH
I had a deep dive in this issue just several days ago and found the root reason by reviewing JDK source code. I think you are using openjdk now. This is a bug in openjdk up to 1.8.0_242. The SSLSessionImpl is not instantiated when it is used in SSLSessionEngine. It is used as a static class, however it is only a final class. The issue has been fixed in 1.8.0_252, so I recommend you to upgrade it to this version. Or switch to any build of Oracle jdk1.8.0, as there is no such bug in it. Hope it helps. Openjdk: SSLSessionEngine.java SSLSessionImpl.java Oracle jdk: SSLSessionEngine.java