hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "daranha3560" <daranha3...@rogers.com>
Subject commons-httpclient-2.0.jar class not found: org\apache\commons\httpclient\HttpMethod
Date Fri, 05 Mar 2004 20:51:18 GMT
Problem: I am getting a runtime error when posting an XML file
via HTTP POST to a servlet running on Tomcat 5.0.18
Error: java.lang.NoClassDefFoundError: org\apache\commons\httpclient\HttpMethod

jdk : Java 2 standard edition version 1.4.2_03
Downloaded software (site : http://jakarta.apache.org/site/binindex.cgi): 
  (downloaded yesterday afternoon)
  Commons FileUpload 1.0 zip; Commons Logging 1.0.3; 
  Commons HttpClient 2.0 zip
Note: Commons HttpClient 2.0 zip was downloaded again (Mar 5) and jar was copied
to j2sdk1.4.2_03\jre\lib\ext, recompiled and run with the same error 

jar files copied to j2sdk1.4.2_03\jre\lib\ext: 
  1. commons-httpclient-2.0.jar
  2. commons-logging.jar
  3. commons-logging-api.jar
  4. commons-fileupload-1.0.jar

Tomcat 5.0.18 and client program are on the same machine
Is any other package required?  Is JSSE required for j2sdk 1.4.2_03?

Please do not send email to my address.   Your help is very much appreciated.

Code is listed below for your convenience (HttpClient sample code: jakarta-comons/httpclient/src/examples)

import java.io.File;
import java.io.FileInputStream;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
import org.apache.commons.httpclient.methods.*;

public class postXML {

  public static void main(String[] args) throws Exception {

           try {
         String strURL = "http://test.ca:80/Test1/fileUpload"; // does not exist; changed
for the mailing list
         String strXMLFilename = "D:\\testXML.xml";
         File input = new File(strXMLFilename);

                PostMethod post = new PostMethod(strURL);
                post.setRequestBody(new FileInputStream(input));
                if (input.length() < Integer.MAX_VALUE) {
                } else {

                post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");
         HttpClient httpclient = new HttpClient();
         int result = httpclient.executeMethod(post);
         System.out.println("Response status code: " + result);
         System.out.println("Response body: ");
            catch (Exception e)
           { e.getMessage(); }
    } // end main
} // end postXML

Thanks for your help.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message