我使用HTTPClient 4.0连接远程服务器并使用HTTPS传输文件。 当我尝试连接时,我得到异常“java.net.SocketException:未实现未连接的套接字”。 请查看堆栈跟踪
java.net.SocketException: Unconnected sockets not implemented
at java.lang.Throwable.<init>(Throwable.java:196)
at java.lang.Exception.<init>(Exception.java:41)
at java.io.IOException.<init>(IOException.java:40)
at java.net.SocketException.<init>(SocketException.java:29)
at javax.net.SocketFactory.createSocket(SocketFactory.java:2)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(Unknown Source)
at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(Unknown Source)
at org.apache.commons.httpclient.HttpConnection.open(Unknown Source)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(Unknown Source)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(Unknown Source)
at org.apache.commons.httpclient.HttpClient.executeMethod(Unknown Source)
at org.apache.commons.httpclient.HttpClient.executeMethod(Unknown Source)
at co.com.personalsoft.ftpseguro.utilidades.TransmisionHTTP.ejecutarTransmisionHTTP(TransmisionHTTP.java:107)
at co.com.personalsoft.ftpseguro.utilidades.TransmisionFTPNew.ejecutarTransmisionAuto(TransmisionFTPNew.java:483)
at co.com.personalsoft.ftpseguro.utilidades.TransmisionFTPNew.ejecutarTransmision(TransmisionFTPNew.java:1016)
at co.com.personalsoft.ftpautomatico.ConexionThread.run(ConexionThread.java:58)
at java.lang.Thread.run(Thread.java:595)
使用HTTP Client 3.1时发现相同的错误。
我的环境 Application Server:Websphere应用程序服务器6.1.0.23 Java:JDK 1.5.0.16
答案 0 :(得分:1)
实际上比压制火更完整的答案是
将com.ibm.ws.admin.client_7.0.0.jar添加到java build
这解决了java.lang.NoClassDefFoundError: com.ibm.ffdc.Manager error
。
添加到设置:
import java.security.Security;
...
Security.setProperty("ssl.SocketFactory.provider", "com.ibm.jsse2.SSLSocketFactoryImpl");
这解决了Cannot find the specified class com.ibm.websphere.ssl.protocol.SSLSocketFactory
答案 1 :(得分:0)
当我启用javax.net.debug时,我注意到有一个缺少的类com.ibm.websphere.com.ibm.websphere.ssl.protocol.SSLSocketFactory。
我在调用httpclient的单元测试中遇到了麻烦。我最终做的是将这一行添加到我的TestClass.setUp()
Security.setProperty("ssl.SocketFactory.provider", "com.ibm.jsse2.SSLSocketFactoryImpl");