i'm writing a dynamic-web-project with wildfly as my web-server by java
in this project, i want to connect with other server
the library i'm using is apache.commons
however, the function works when i run as application
but once i run as server, it comes out an exception, NoClassDefFoundError, pointing at the line i new the object
( ConnectUtil util = new ConnectUtil() ) <- line of error triggered
i have tried to import the .jar below but still not working
how can i solve this?
here's some code in ConnectUtil.java:
public Response openUrl(String host, String url, int port,
HashMap<String, String> params, int timeout) {
Response result = new Response();
// init PostMethod object.
Protocol mHttps = new Protocol("https", new EasySSLProtocolSocketFactory(), port);
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost(host, port, mHttps);
client.getHttpConnectionManager().getParams().setConnectionTimeout(timeout);
client.getHttpConnectionManager().getParams().setSoTimeout(timeout);
byte[] response = null;
PostMethod method = new PostMethod(url);
try {
int code = client.executeMethod(method);
} catch (Exception e) {
logger.error(ExceptionUtil.getPlainStackTrace(e));
} finally {
if (method != null)
method.releaseConnection();
}
return result;
}
and the stack trace is:
ERROR [io.indertow.request] (default-55) UT005023: Exception handling request to /MyWebServicePath: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/protocal/SecureProtocalSocketFactory
error happens when ConnectUtil util = new ConnectUtil()
thanks