1 Reply Latest reply on Dec 2, 2015 1:10 AM by swd847

    java.lang.ClassNotFoundException: javax.net.ssl.SSLSocketFactory When using rest easy with JAVA 8 on WildFly8.2.0

    sreenathac

      I am using rest easy for getting and posting the data from a third party URL, When I am calling the get service using the below code I am getting the ClassNotFoundException "javax.net.ssl.SSLSocketFactory"

      final ClientRequest request = createRequest(url,acceptType,consumesType,body);

      final byte[] encodedCredentials = (userName + ":" + password) .getBytes();

      final String encodedAuto = Base64.encodeBytes(encodedCredentials);

      request.header("Authorization", "Basic " + encodedAuto);

      try {

      request.addAuthenticationHeaders(request, userName, password);

      response = request.get(String.class);

      if (response != null)

           {

      logger.info("Status of the REST Call:" + response.getStatus());

            }

      } catch (final Exception e) {

      e.printStackTrace();

      }

       

      And the createRequest method is as below

      public ClientRequest createRequest(final String urlString, final String acceptType, final String consumesType, final String body) {

      final ClientRequest request = new ClientRequest(urlString);

      request.accept(acceptType);

      if (body != null) {

      request.body(consumesType, body);

            }

      request.header("Content-Type", consumesType);

      // request.header("Accept", acceptType);

      return request;

      }

      When it is executing response = request.get(request); it is throwing SSLSocketFactory ClassNotFoundException, as per my analysis this class is available on rt.jar which is not required to add to the WildFly server or deployments lib folder.

      Caused by: java.lang.NoClassDefFoundError: javax/net/ssl/SSLSocketFactory at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:82) [commons-httpclient-3.1.jar:] at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:127) [commons-httpclient-3.1.jar:] at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707) [commons-httpclient-3.1.jar:] at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387) [commons-httpclient-3.1.jar:] at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) [commons-httpclient-3.1.jar:] at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) [commons-httpclient-3.1.jar:] at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) [commons-httpclient-3.1.jar:] at org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor.execute(ApacheHttpClientExecutor.java:81) [resteasy-jaxrs-2.2.1.GA.jar:] at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:39) [resteasy-jaxrs-2.2.1.GA.jar:] at org.jboss.resteasy.security.doseta.DigitalSigningInterceptor.execute(DigitalSigningInterceptor.java:107) [resteasy-crypto-3.0.10.Final.jar:] at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:45) [resteasy-jaxrs-2.2.1.GA.jar:] at org.jboss.resteasy.plugins.interceptors.encoding.AcceptEncodingGZIPInterceptor.execute(AcceptEncodingGZIPInterceptor.java:40) [resteasy-jaxrs-2.2.1.GA.jar:] at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:45) [resteasy-jaxrs-2.2.1.GA.jar:] at org.jboss.resteasy.client.ClientRequest.execute(ClientRequest.java:473) [resteasy-jaxrs-2.2.1.GA.jar:] at org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:704) [resteasy-jaxrs-2.2.1.GA.jar:] at org.jboss.resteasy.client.ClientRequest.get(ClientRequest.java:509) [resteasy-jaxrs-2.2.1.GA.jar:] at org.jboss.resteasy.client.ClientRequest.get(ClientRequest.java:537) [resteasy-jaxrs-2.2.1.GA.jar:] at com.example.main.framework.service.RestClientService.get(RestClientService.java:46) [main-ejb.jar:] at com.example.main.entity.validator.EntityValidator.getPMAccountDetails(EntityValidator.java:2866) [main-ejb.jar:] at com.example.main.entity.validator.EntityValidator.validateCompanySettingPortfolioMgr(EntityValidator.java:2633) [main-ejb.jar:] at com.example.main.action.codegen.CompanySettingPortfolioMgrHome.persist(CompanySettingPortfolioMgrHome.java:329) [main-ejb.jar:] ... 99 more Caused by: java.lang.ClassNotFoundException: javax.net.ssl.SSLSocketFactory from [Module "org.apache.commons.httpclient:main" from local module loader @6043cd28 (finder: local module finder @cb51256 (roots: D:\wildfly-8.2.0.Final\modules,D:\wildfly-8.2.0.Final\modules\system\layers\base))] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final] at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final] ... 120 more 

      If we add rt.jar to the wildfly module then it throws ClassNotFoundException related to classes in jsse.jar which is as part of JDK 1.8 lib. Then I realized that we should not add these jars to neither httpclient module nor deployment lib folder.

      Please let me know if any one has solution for this issue.