cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.ClassCastException: HttpsURLConnection

chris_obniala
Newcomer
0 Kudos

We're trying to implement a java map in our system (SAP PI 7.5). Inside this java map is a custom library that creates an https connection to another server. The library uses the javax.net.ssl package to do that. For our map to initialize the connection, we can only use a function available in the library which is described below:

httpConfig = HttpPublicKeyRepository.HttpConfig.builder()
		.baseURL("https://server:port")
		.sslContext(loadSSLContext("TrustedCAs"))
		.retryContext(HttpClientWithRetry.DEFAULT_RETRY_CONTEXT)
		.environment(env)
		.build();

Upon running the application, we encountered the following error.

java.lang.ClassCastException: com.sap.engine.httpdsrclient.protocols.instrumented.https.DSRHttpsURLConnection (loaded by library:tc~bl~dsrhttpclient@96432 com.sap.engine.boot.loader.ResourceMultiParentClassLoader) cannot be cast to javax.net.ssl.HttpsURLConnection (loaded by <bootstrap>)

How can we ensure that our program will use the HttpsURLConnection under javax.net.ssl and not the one defined in the VM parameter java.protocol.handler.pkgs?

Accepted Solutions (0)

Answers (1)

Answers (1)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Christopher,

Please try removing all import statements related to java.protocol.handler.pkgs .

Then try to execute the code containing on this part of the code.

Java will show you exact error.

Regards

Anupam