问题
When I try to use okhttp
or javax.ws.rs.client.Client
the following error occur
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
Searching in the sun.security.ssl package, there is no SSLSessionImpl class
Im using Mac OS 10.13.3 (17D102)
java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
And running my war on Glassfish 5.0
build.gradle
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
}
}
group 'invoice-administration-api'
version '1.0-SNAPSHOT'
apply plugin: 'idea'
apply plugin: 'war'
apply plugin: 'kotlin'
apply plugin: 'kotlin-jpa'
apply plugin: 'kotlin-allopen'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compileOnly group: 'javax', name: 'javaee-api', version: '8.0'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.13.Final'
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version: '2.26'
}
allOpen {
annotation('javax.ejb.Stateless')
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
回答1:
EDIT: since this is the "correct answer" and Java 1.8.0-151 will potentialy lack security patches. I can't recommend to downgrade to a such an old Java version.
Please take a look at Payara project or new releases of Glassfish.
--
Try to downgrade the Java version to Java 1.8.0-151. It should work.
There's an issue in glassfish 5 with Java 8 161, there's an issue created, but no changes in nightly builds regarding the issue, I checked yesterday (19th march).
回答2:
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.
回答3:
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
回答4:
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
回答5:
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.
来源:https://stackoverflow.com/questions/49383650/sun-security-ssl-sslsessionimpl-not-found