Quantcast
Channel: VMware Communities : Discussion List - vSphere Client SDK
Viewing all articles
Browse latest Browse all 2218

Not able to connect to HTTPS endpoint within Webclient Service layer - HELP!

$
0
0

Hi,

We are currently hitting a show-stopper issue which is preventing us from being able to deliver and certify our plugin. Would you please be able to help?

Our code originated from the plugin-seed 0.9.7. It uses a custom data adapter to connect to our appliance's REST API and retrieve data. This works well when we are connecting to an HTTP endpoint (using RestTemplate), and the data is all returned as expected.

However, when attempting to connect to an HTTPS endpoint, the connection fails as it is not authorised (due to SSL). This is expected behaviour, and we have tried to circumvent this using the code provided here: http://www.baeldung.com/httpclient-ssl

This code works as expected, and returns our data when built within a simple Java application with required dependencies (including introduced Apache HTTP libraries).

However, when we try running the code within the plugin we get a failure on installation to the Virgo server, as follows:

Application context creation failure for bundle 'biz.runecast.rc2plugin.rc2plugin-service' version '1.0.0'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'RunecastDataClient' defined in URL [bundleentry://323.fwk1376790324/META-INF/spring/bundle-context.xml]: Instantiation of bean failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "org.springframework.web.client.RestTemplate.setRequestFactory(Lorg/springframework/http/client/ClientHttpRequestFactory;)V" the class loader (instance of org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoader) of the current class, biz/runecast/rc2plugin/services/RunecastDataClient, and the class loader (instance of org/eclipse/virgo/kernel/userregion/internal/equinox/KernelBundleClassLoader) for the method's defining class, org/springframework/http/client/support/HttpAccessor, have different Class objects for the type org/springframework/http/client/ClientHttpRequestFactory used in the signature

We believe all the required dependencies are there, equivalent to the dependencies in our simple application. These are included in the Manifest and included within the JAR on build (Bundle-Classpath). I have included the MANIFEST.MF with the post.

The project builds the .JAR fine using ANT. When our class is being statically initialised, the error occurs at the point shown below:

private static SSLContext sslContext; private static CloseableHttpClient httpClient; private static ClientHttpRequestFactory httpRequestFactory; private static RestTemplate restTemplate = new RestTemplate();     static {         try {             sslContext = new SSLContextBuilder()                     .loadTrustMaterial(null, new TrustStrategy() {                         @Override                         public boolean isTrusted(X509Certificate[] certificate, String authType)                                 throws CertificateException {                             return true;                         }                     }).build();         } catch (KeyManagementException e) {             // TODO Auto-generated catch block             e.printStackTrace();         } catch (NoSuchAlgorithmException e) {             // TODO Auto-generated catch block             e.printStackTrace();         } catch (KeyStoreException e) {             // TODO Auto-generated catch block             e.printStackTrace();         }         httpClient = HttpClients.custom()                 .setSSLContext(sslContext)                 .setSSLHostnameVerifier(new NoopHostnameVerifier())                 .build();         httpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);         restTemplate.setRequestFactory(httpRequestFactory); //<---- This is causing error    }

 

This is preventing us from continuing any work on the plugin. We have no idea how to proceed towards a solution. Could you please let us know what we can do, or what we can provide, to diagnose and solve this problem ASAP?

Many thanks,

Warren


Viewing all articles
Browse latest Browse all 2218

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>