0

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

  • comments-codec-1.10
  • comments-fileupload-1.3.1
  • comments-httpclient-3.1
  • comments-io-2.4
  • comments-lang-2.6
  • comments-logging-1.2
  • comments-ssl
  • 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

    Andrew
    • 1
    • 1
    • Show your code and the stacktrace. – Jens Mar 27 '15 at 06:54
    • try changing comments-codec to version 1.2. At least that's the dependency the httpclient wants for version 3.1. Not sure if it will solve your issue though. – Ria Mar 27 '15 at 08:20
    • It is really SecureProtocalSocketFactory` and not `SecureProtocolSocketFactory`? – Ria Mar 27 '15 at 08:23
    • i changed to version 1.2 but still the same error. And it is `SecureProtocolSocketFactory` my mistake, sorry for confusing – Andrew Mar 27 '15 at 08:36
    • maybe can help you http://stackoverflow.com/questions/27517758/wildfly-8-1-classnotfound-org-apache-http-conn-clientconnectionmanager – Federico Sierra Mar 27 '15 at 13:08
    • i added the jboss-deployment-structure.xml and loaded successfully, but still got the same error message. my module name is following `` – Andrew Apr 02 '15 at 03:14

    0 Answers0