3

I have this piece of code that directly processes the response out of a REST client:

 uc = (HttpURLConnection) u.openConnection();
 uc.setConnectTimeout(2000);
 uc.setDoOutput(true);

 out = new OutputStreamWriter(uc.getOutputStream());
 out.write(posturl);
 out.flush();
 rd = new BufferedReader(new InputStreamReader(uc.getInputStream()));

When I run this code (actually it is a jar run my a BPEL within OpenESB) I get the following exception:

java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext) cause java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)

I'm not sure what's happening here let alone solve it. I guess this is related to the endpoint being a HTTPs server. I have little experience myself with HTTPs so I'm not sure what's the cause or what to do to fix it.

Full StackTrace (or as full as OpenESB offers):

java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
    at javax.net.ssl.DefaultSSLSocketFactory.throwException(SSLSocketFactory.java:198)
    at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:205)
    at sun.net.www.protocol.https.HttpsClient.createSocket(HttpsClient.java:361)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:162)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:378)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:473)
    at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:270)
    at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:327)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:931)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1090)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
    at es.myapp.OpenAMRESTAuthentication.readURLResponse(OpenAMRESTAuthentication.java:157)
    at es.myapp.OpenAMRESTAuthentication.authenticate(OpenAMRESTAuthentication.java:60)
    at es.myapp.OpenAMRESTAuthentication.authenticate(OpenAMRESTAuthentication.java:94)
    at es.myapp.AuthSingleton.authenticate(AuthSingleton.java:82)
4
  • 1
    Could you post the complete Stacktrace? Normally the real culprit is elsewhere and this is just a symptom. Commented Feb 2, 2016 at 11:55
  • It should be HttpsURLConnection. Can u typecast u.open connection to HttpsURLConnection and try. Commented Feb 2, 2016 at 12:03
  • 1
    Could be related - stackoverflow.com/questions/9761575/… Commented Feb 2, 2016 at 12:04
  • @MadhusudanaReddySunnapu I can't do that; this is a jar that's on my web server. It's supposed to work with the endpoint, and I've seen it working on other applications. Commented Feb 2, 2016 at 12:08

1 Answer 1

1

Solved it! Thanks to @Daniel for pointing out to a similar answer, turns out my OpenESB had these startup parameters:

"-Djavax.net.ssl.keyStore=%OPENESB_HOME%/keystore.jks" "-Djavax.net.ssl.trustStore=%OPENESB_HOME%/cacerts.jks" -Djavax.net.ssl.keyStorePassword=changeit

Removed them and it works again :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.