Hi Diana,

It sounds like you are having class loader problems. Either there is more than one instance of the HttpClient jar on the classpath (e.g. one in common/lib and one in WEB-INF/lib) or there is some bug with Tomcat. My guess is that it's the first.

Mike

On Mar 5, 2004, at 3:51 PM, daranha3560 wrote:

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


Environment:
WINNT 4.0
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) postXML.java:

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) {
post.setRequestContentLength((int)input.length());
} else {
post.setRequestContentLength(EntityEnclosingMethod.CONTENT_LENGTH_CHUNK ED);
}


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: ");
         System.out.println(post.getResponseBodyAsString());

         post.releaseConnection();
          }
            catch (Exception e)
           { e.getMessage(); }
    } // end main
} // end postXML

Thanks for your help.

Diana



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to