不知道其他人是否看到過這種情況,但我無法弄清楚交易是什麼... 我正在使用Liberty Profile 8.5.5.1和IBM JDK 7 pxi3270sr5-20130619_01( SR5)Liberty Profile和Apache HttpClient 4.2.1
我有一個類需要到另一個服務器(基於PHP)的URL請求。所以我寫了一個HttpHelper類來調用Apache HttpClient類。如果我從簡單的Java應用程序調用我的幫助程序,我沒有問題。當我內自由運行完全相同的代碼,我得到一個ClassNotFound的誤差javax.net.ssl.SSLSocket中
這裏是我的代碼調用阿帕奇類...
public class HttpClientHelper
{
static Logger LOGGER = Logger.getLogger(HttpClientHelper.class.getName());
static String cname = HttpClientHelper.class.getName();
static HttpClientHelper _instance = null;
static PoolingClientConnectionManager _cm = null;
private HttpClientHelper()
{
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(
new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
_cm = new PoolingClientConnectionManager(schemeRegistry);
_cm.setMaxTotal(200);
_cm.setDefaultMaxPerRoute(20);
HttpHost shost = new HttpHost("joomla32.cal2.net", 80);
_cm.setMaxPerRoute(new HttpRoute(shost), 50);
}
protected static HttpClientHelper getInstance() {
if (_instance == null) {
_instance = new HttpClientHelper();
}
return _instance;
}
public static String getUrlBody(String url) {
String method = "getUrlBody(String url)";
LOGGER.entering(cname, method, url);
getInstance();
String val = null;
DefaultHttpClient httpclient = null;
try {
HttpContext context = new BasicHttpContext();
httpclient = new DefaultHttpClient(_cm);
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget, context);
HttpEntity entity = response.getEntity();
System.out.println(response.getStatusLine());
val = EntityUtils.toString(entity);
EntityUtils.consume(entity);
} catch (Exception e) {
LOGGER.logp(Level.WARNING, cname, method, e.getMessage(), url);
}catch(Error e){
LOGGER.logp(Level.INFO,cname,method,e.getMessage());
e.printStackTrace();
}
finally{
LOGGER.exiting(cname, method, val);
}
return val;
}
}
\
錯誤被引發到httpclient.execute(httpget,context);
我已經嘗試將SSL更新添加到IBM JDK,但沒有奏效。 ssl.SocketFactory.provider = com.ibm.jsse2.SSLSocketFactoryImpl ssl.ServerSocketFactory.provider = com.ibm.jsse2.SSLServerSocketFactoryImpl
任何幫助,將不勝感激
完全正確..這正是我要問的。 ;) – ebullient