Results 1 to 5 of 5
  1. #1
    int80 is offline Member
    Join Date
    Jul 2008
    Rep Power

    Default Getting httpclient working with eclipse.

    I've been trying to get the HttpClient API working with eclipse to no avail. Whenever I try and compile the code I get this error:

    Java Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    	at org.apache.commons.httpclient.HttpClient.<clinit>(
    	at httpClient.htttp.main(
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    	at$ Source)
    	at Method)
    	at Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    	... 2 more
    Java Code:
    package httpClient;
    import org.apache.commons.httpclient.*;
    import org.apache.commons.httpclient.methods.*;
    import org.apache.commons.httpclient.params.HttpMethodParams;
    public class htttp {
      private static String url = "";
      public static void main(String[] args) {
        // Create an instance of HttpClient.
        HttpClient client = new HttpClient();
        // Create a method instance.
        GetMethod method = new GetMethod(url);
        // Provide custom retry handler is necessary
        		new DefaultHttpMethodRetryHandler(3, false));
        try {
          // Execute the method.
          int statusCode = client.executeMethod(method);
          if (statusCode != HttpStatus.SC_OK) {
            System.err.println("Method failed: " + method.getStatusLine());
          // Read the response body.
          byte[] responseBody = method.getResponseBody();
          // Deal with the response.
          // Use caution: ensure correct character encoding and is not binary data
          System.out.println(new String(responseBody));
        } catch (HttpException e) {
          System.err.println("Fatal protocol violation: " + e.getMessage());
        } catch (IOException e) {
          System.err.println("Fatal transport error: " + e.getMessage());
        } finally {
          // Release the connection.

    Also, does anyone know how to get JyDT working in eclipse and also any good tutorials on the Java scripting API using (J)Python. The only tutorials I could find was using Javascript. I don't really understand the point in being able to use Javascript in a Java program, but I can python...

    Anyway, I appreciate any answers.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    Whenever I try and compile the code I get this error:
    That's strange. It looks just like what you'd get trying to execute a program.

    Where is the class: org/apache/commons/logging/LogFactory
    defined? Probably in a jar file. That jar file needs to be on the classpath when the program is executed.

  3. #3
    racerxadam is offline Member
    Join Date
    Jul 2008
    Rep Power


    Right click on your class file
    Select configure build path
    Click the libraries tab
    Make sure the commons logging jar is in the list of libraries, if not add it

  4. #4
    int80 is offline Member
    Join Date
    Jul 2008
    Rep Power


    Woohoo!!! I got it working. Basically, it was a long list of dependencies that weren't stated anywhere (clearly at least) that were needed.

    Commons codec and commons logging from

    Thanks norm (again) && racerxadam.
    Last edited by int80; 09-16-2008 at 09:15 PM.

  5. #5
    Join Date
    Mar 2009
    Rep Power

    Default NoClassDefFoundError

    i have try with eclipse and with netbeans both, i have included the common loggin and common codec jar file also. but still it not resolve the error. i also put these jar files inside the jdk where its installed and also where my class file (.java) exists.

    i will appreciate the help from every one.


Similar Threads

  1. Eclipse debug not working on Windows Vista
    By mathew.vinay in forum Eclipse
    Replies: 5
    Last Post: 04-04-2009, 02:06 PM
  2. keyListener isn't working for me
    By lost_in_java in forum AWT / Swing
    Replies: 7
    Last Post: 12-05-2008, 05:24 AM
  3. ant no longer working
    By varun077 in forum Eclipse
    Replies: 1
    Last Post: 07-25-2008, 10:57 AM
  4. Replies: 8
    Last Post: 05-28-2008, 08:00 AM
  5. Working With ANT
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 04-26-2007, 09:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts