Eclipse : clientBuilder.sslSocketFactory not supported on JDK 9+

Viewed 20425

I'm getting this error on Eclipse oxygen 4.7.0, java 1.8

clientBuilder.sslSocketFactory not supported on JDK 9+

related to Eclipse, maven ..trying to update Maven : Alt+f5 the module okhttp3 trying to connect .. when resolving/processing pom

I dont have JDK9 at all. Looked at all the other similar reports on stackoverflow, none is related.

6 Answers

You can find a similar issue in Eclipse bug 517113, with JDK8.

The error call stack indicates an external dependencies to a library compiled with OpenJDK

As seen here, check also your JDK declaration in your Eclipse

I changed code which was using JAVA_HOME as JRE coming with SonarScanner package.
Once I changed it to default JAVA_HOME, it started working fine.

Other possible cause: wrong dependency, as show by PR 3066 or this question.

I think you are running Eclipse Oxygen with JDK 9.

If you don't want to, then I have a solution for that.

Update the eclipse/eclipse.ini by adding -vm parameter:

-startup
plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.700.v20180518-1200
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
C:/Program Files/Java/jdk1.8.0_251/bin
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=1.8
-Dosgi.dataAreaRequiresExplicitInit=true
-Xms256m
-Xmx1024m
--add-modules=ALL-SYSTEM

This .ini file is from my latest eclipse. It may be different for other versions.

This will enforce eclipse to start with the JDK that you have added.

Note: -Dosgi.requiredJavaVersion=1.8 will give you information upto which java version the eclipse can support.

If anyone has come to face this issue when running Azul's zulu8 open jdk, try by taking zulu8 jdk of say 3-4 versions behind the latest. That worked for me.

Check your OkHttpClient.Builder(), change code from

sslSocketFactory(SSLSocketFactory sslSocketFactory)

to

sslSocketFactory(SSLSocketFactory sslSocketFactory, X509TrustManager trustManager)

For example:

// define sslContext ...

new OkHttpClient.Builder().sslSocketFactory(sslContext.getSocketFactory(), new JEEX509TrustManager()).build();

And then everything will be ok.

There are two versions of Java 8 as below:

  1. Java SE 8 (8u211 and later)
  2. Java SE 8 (8u202 and earlier)

So if you have installed "Java SE 8 (8u211 and later)" you will receive error: clientBuilder.sslSocketFactory not supported on JDK 9+ in eclipse oxygen. To avoid this error please install "Java SE 8 (8u202 and earlier)" from below link https://www.oracle.com/java/technologies/downloads/archive/

I followed these steps to remove this error: Earlier Code:

OkHttpClient.Builder builder = new OkHttpClient.Builder(); 
 builder.sslSocketFactory(sslSocketFactory);

New Code:

OkHttpClient.Builder builder = new OkHttpClient.Builder(); 
 X509TrustManager trustManager = new X509DeployTrustManager();
 builder.sslSocketFactory(sslSocketFactory);
Related