我有这段代码直接处理来自REST客户端的响应:

 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()));

当我运行此代码时(实际上是一个罐子,在OpenESB中运行一个BPEL),出现以下异常:
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)

我不确定这里发生了什么,更不用说解决了。我想这与端点是HTTPs服务器有关。我对HTTP的了解很少,所以我不确定是什么原因或如何解决它。

完整的StackTrace(或与OpenESB提供的一样完整):
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)

最佳答案

解决了!感谢@Daniel指出了类似的答案,原来我的OpenESB具有以下启动参数:

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

删除它们,它可以再次工作:)

09-25 22:23