java.lang.NoClassDefFoundError: sun/security/ssl/HandshakeStateManager
java.lang.NoClassDefFoundError: sun/security/ssl/HandshakeStateManager
我目前在 NetBean IDE 中从事 Web 服务方面的工作。
我正在使用 Apache HttpClient
向某些 RESTful API 发送 GET
请求。
问题是,它在 junit 测试中运行得非常好,但是当我编译它并 delpoy 到 glassfish 时,它显示以下错误:
Info: wsimport successful
Severe: sun/security/ssl/HandshakeStateManager
java.lang.NoClassDefFoundError: sun/security/ssl/HandshakeStateManager
at sun.security.ssl.Handshaker.init(Handshaker.java:282)
at sun.security.ssl.Handshaker.<init>(Handshaker.java:242)
at sun.security.ssl.ClientHandshaker.<init>(ClientHandshaker.java:160)
at sun.security.ssl.SSLSocketImpl.initHandshaker(SSLSocketImpl.java:1329)
at sun.security.ssl.SSLSocketImpl.doneConnect(SSLSocketImpl.java:690)
at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:569)
at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:110)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:393)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:384)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
这是我发送 GET
请求的代码。有什么问题?
protected String getResponse(String url) throws IOException, ProviderNotAvailableException{
HttpGet request = new HttpGet(url);
CloseableHttpResponse response = httpClient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null) {
String result = EntityUtils.toString(entity);
return result;
} else {
throw new ProviderNotAvailableException("Http entity is null.");
}
}
我的jdk版本是1.8,NetBean版本是11.0。同样,它在 junit 测试中运行良好。
我曾经使用 JDK v1.8。升级到 1.8u221,问题解决。
我目前在 NetBean IDE 中从事 Web 服务方面的工作。
我正在使用 Apache HttpClient
向某些 RESTful API 发送 GET
请求。
问题是,它在 junit 测试中运行得非常好,但是当我编译它并 delpoy 到 glassfish 时,它显示以下错误:
Info: wsimport successful
Severe: sun/security/ssl/HandshakeStateManager
java.lang.NoClassDefFoundError: sun/security/ssl/HandshakeStateManager
at sun.security.ssl.Handshaker.init(Handshaker.java:282)
at sun.security.ssl.Handshaker.<init>(Handshaker.java:242)
at sun.security.ssl.ClientHandshaker.<init>(ClientHandshaker.java:160)
at sun.security.ssl.SSLSocketImpl.initHandshaker(SSLSocketImpl.java:1329)
at sun.security.ssl.SSLSocketImpl.doneConnect(SSLSocketImpl.java:690)
at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:569)
at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:110)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:393)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:384)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
这是我发送 GET
请求的代码。有什么问题?
protected String getResponse(String url) throws IOException, ProviderNotAvailableException{
HttpGet request = new HttpGet(url);
CloseableHttpResponse response = httpClient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null) {
String result = EntityUtils.toString(entity);
return result;
} else {
throw new ProviderNotAvailableException("Http entity is null.");
}
}
我的jdk版本是1.8,NetBean版本是11.0。同样,它在 junit 测试中运行良好。
我曾经使用 JDK v1.8。升级到 1.8u221,问题解决。