You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Neelesh Bodas <ne...@gmail.com> on 2006/06/22 19:41:29 UTC

Logging related problem with HttpClient

Hello,

I am having problems while using HttpClient. Here is a sample code :

package src.com.example.web;
// all necessary imports
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;


public class Sample {

	private static String url = "http://www.apache.org/";

	  public static void main(String[] args) {
	    // Create an instance of HttpClient.
	    HttpClient client = new HttpClient();

	  }
}

I have made sure that following jars are in the classpath :
commons-codec-1.3.jar
commons-logging-1.1.jar
commons-logging-adapters-1.1.jar
commons-logging-api-1.1.jar
junit-4.1.jar
commons-httpclient-3.0.1.jar

I am getting the following runtime error:

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/logging/LogFactory
	at org.apache.commons.httpclient.HttpClient.<clinit>(HttpClient.java:65)
	at src.com.example.web.Sample.main(Sample.java:12)

I have also tried using log4j but that didnot solve the problem. (As
an aside I am using Java 5.0 so I thing the logging facility provided
by java.util should be fine)

Any pointers regarding how to remove this error and get the code working?

Thanks in Advance
~Neelesh

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [logging] Logging related problem with HttpClient

Posted by Simon Kitching <sk...@apache.org>.
Hi Neelesh/Ortwin,

While the library being used is HttpClient, the problem does seem to
really be a commons-logging(JCL)issue, and therefore belongs on this
list. I've changed the subject of this email to indicate this.

The httpclient 3.0.1 dependencies do specify commons-logging 1.0.3, but
the latest version (1.1) should be 100% backwards compatible while
having a lot less bugs, so logging 1.1 should be the right version to
use in this case.

In general, the commons-logging-api jar is intended only for use by
Apache Tomcat (and maybe other container frameworks). You might want to
use the full jar, or possibly the -adapters one if you're running this
code in a container that already deploys JCL.

>>From the exception stacktrace it looks like you're writing some sort of
webapp, running in some sort of container:
org/apache/commons/logging/LogFactory
org.apache.commons.httpclient.HttpClient.<clinit>(HttpClient.java:65)
src.com.example.web.Sample.main(Sample.java:12)

This page might be helpful:
  http://jakarta.apache.org/commons/logging/troubleshooting.html
If this doesn't solve your problem, then please post further details of
the environment you're actually running this code in.

Regards,

Simon

On Thu, 2006-06-22 at 19:47 +0200, Ortwin Glück wrote:
> Neelesh,
> 
> Please see http://jakarta.apache.org/commons/httpclient/dependencies.html
> for the correct version of the dependencies.
> 
> Note: HttpClient is no longer in Jakarta Commons. Our mailing lists are
> these:
> http://jakarta.apache.org/commons/httpclient/mail-lists.html
> 
> Cheers
> 
> Ortwin
> 
> Neelesh Bodas wrote:
> > I have made sure that following jars are in the classpath :
> > commons-codec-1.3.jar
> > commons-logging-1.1.jar
> > commons-logging-adapters-1.1.jar
> > commons-logging-api-1.1.jar
> > junit-4.1.jar
> > commons-httpclient-3.0.1.jar
> > 
> > I am getting the following runtime error:
> > 
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > org/apache/commons/logging/LogFactory
> >     at
> > org.apache.commons.httpclient.HttpClient.<clinit>(HttpClient.java:65)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: Logging related problem with HttpClient

Posted by Ortwin Glück <od...@odi.ch>.
Neelesh,

Please see http://jakarta.apache.org/commons/httpclient/dependencies.html
for the correct version of the dependencies.

Note: HttpClient is no longer in Jakarta Commons. Our mailing lists are
these:
http://jakarta.apache.org/commons/httpclient/mail-lists.html

Cheers

Ortwin

Neelesh Bodas wrote:
> I have made sure that following jars are in the classpath :
> commons-codec-1.3.jar
> commons-logging-1.1.jar
> commons-logging-adapters-1.1.jar
> commons-logging-api-1.1.jar
> junit-4.1.jar
> commons-httpclient-3.0.1.jar
> 
> I am getting the following runtime error:
> 
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/logging/LogFactory
>     at
> org.apache.commons.httpclient.HttpClient.<clinit>(HttpClient.java:65)


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org