You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Graeme <co...@hotmail.com> on 2005/09/12 06:26:00 UTC

ExceptionInInitializerError Error as soon as I Run

I have copied the tutorial here:
http://jakarta.apache.org/commons/httpclient/tutorial.html
So I know there are no errors in my code and I am sure I have all the
dependencies in the classpath but I still get these errors as soon as I run
it:

Exception in thread "main" java.lang.ExceptionInInitializerError
        at HttpClientTutorial.main(HttpClientTutorial.java:13)
Caused by: org.apache.commons.logging.LogConfigurationException:
java.lang.Class
NotFoundException: org.apache.commons.logging.impl.LogFactoryImpl (Caused by
jav
a.lang.ClassNotFoundException:
org.apache.commons.logging.impl.LogFactoryImpl)
        at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:579)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:517)

        at
org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:316)

        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
        at
org.apache.commons.httpclient.HttpClient.<clinit>(HttpClient.java:65)

        ... 1 more
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.logging.impl.Log
FactoryImpl
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:530)
        ... 6 more

Any one have any ideas of why I am getting this error?
Thank you

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


RE: ExceptionInInitializerError Error as soon as I Run

Posted by Roland Weber <RO...@de.ibm.com>.
Hi Graeme,

> Although for future reference is it not possible to make java read the 
.jar
> files in the classpath directory so I don't need to add them each time 
to
> the classpath?

Personally, I'm using initialization scripts to set the CLASSPATH variable
according to the project on which I'm working. I don't know whether Java
will automatically scan for JAR files if you append the directory. You
should check the JDK documentation for that.

It is possible to copy JAR files to the lib directories of the JRE, but I
recommend not to do that. They could end up in different class loaders 
than
expected, which creates all kinds of problems especially with 
commons-logging.

cheers,
  Roland

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


RE: ExceptionInInitializerError Error as soon as I Run

Posted by Graeme <co...@hotmail.com>.
Thank you Roland,

After reading what you had sent me I realized that I had been downloading
the wrong files. I was download the source files not the Binary files,
therefore I did not see any .jar files so I tried extracting them and
putting all the files in the folders.

Now that I have the right binary files and extracted just the .jar files
then set the classpath to include those 3 .jar files I was able to run the
program successfully.

Although for future reference is it not possible to make java read the .jar
files in the classpath directory so I don't need to add them each time to
the classpath?

But in the meantime,
Thank you very much for helping me with this.

-----Original Message-----
From: Roland Weber [mailto:ROLWEBER@de.ibm.com] 
Sent: 12 September 2005 07:56
To: HttpClient User Discussion
Subject: RE: ExceptionInInitializerError Error as soon as I Run

Hi Graeme,

> Thanks for that
> I take it I am right in putting the commons-logging here:
> C:\Program Files\Java\jdk1.5.0_04\classpath\org\apache\commons\logging
> Is that's how its suppose to look like. In the Logging folder are files 
like
> LogConfigurationException and LogFactory for example and the folder impl

No, that is most likely wrong. The org/apache/commons/logging package 
prefix
is defined in the JAR file. Putting a file into the classpath usually 
means
defining the CLASSPATH environment variable to include the file:

setenv CLASSPATH x:\Projects\MyProject\lib\commons-logging.jar

Likewise for the other dependency required at runtime:

setenv CLASSPATH 
x:\Projects\MyProject\lib\commons-logging.jar;x:\Projects\MyProject\lib\comm
ons-codec.jar

> I don't quite understand the configuring. Since the Tutorial doesn't go 
into
> that so I am not entirely sure what I am suppose to do I am not even 
sure
> what file I am suppose to edit in the common-logging.

You can forget about configuring right now. Once you fixed your classpath
issues, HttpClient should work with a reasonable default configuration.

hope that helps,
  Roland

> 
> 
> -----Original Message-----
> From: Roland Weber [mailto:ROLWEBER@de.ibm.com] 
> Sent: 12 September 2005 06:49
> To: HttpClient User Discussion
> Subject: Re: ExceptionInInitializerError Error as soon as I Run
> 
> Hi Graeme,
> 
> > I have copied the tutorial here:
> > http://jakarta.apache.org/commons/httpclient/tutorial.html
> > So I know there are no errors in my code and I am sure I have all the
> > dependencies in the classpath but I still get these errors as soon as 
I 
> run
> > it:
> > 
> > Exception in thread "main" java.lang.ExceptionInInitializerError
> >         at HttpClientTutorial.main(HttpClientTutorial.java:13)
> > [...]
> > Caused by: java.lang.ClassNotFoundException:
> > org.apache.commons.logging.impl.Log
> > FactoryImpl
> 
> It looks like you are missing commons-logging.
> 
> 1) verify the dependencies in the classpath again:
> http://jakarta.apache.org/commons/httpclient/dependencies.html
> 
> 2) verify the logging configuration:
> http://jakarta.apache.org/commons/httpclient/logging.html
> 
> hope that helps,
>   Roland
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 


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


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


RE: ExceptionInInitializerError Error as soon as I Run

Posted by Roland Weber <RO...@de.ibm.com>.
Hi Graeme,

> Thanks for that
> I take it I am right in putting the commons-logging here:
> C:\Program Files\Java\jdk1.5.0_04\classpath\org\apache\commons\logging
> Is that's how its suppose to look like. In the Logging folder are files 
like
> LogConfigurationException and LogFactory for example and the folder impl

No, that is most likely wrong. The org/apache/commons/logging package 
prefix
is defined in the JAR file. Putting a file into the classpath usually 
means
defining the CLASSPATH environment variable to include the file:

setenv CLASSPATH x:\Projects\MyProject\lib\commons-logging.jar

Likewise for the other dependency required at runtime:

setenv CLASSPATH 
x:\Projects\MyProject\lib\commons-logging.jar;x:\Projects\MyProject\lib\commons-codec.jar

> I don't quite understand the configuring. Since the Tutorial doesn't go 
into
> that so I am not entirely sure what I am suppose to do I am not even 
sure
> what file I am suppose to edit in the common-logging.

You can forget about configuring right now. Once you fixed your classpath
issues, HttpClient should work with a reasonable default configuration.

hope that helps,
  Roland

> 
> 
> -----Original Message-----
> From: Roland Weber [mailto:ROLWEBER@de.ibm.com] 
> Sent: 12 September 2005 06:49
> To: HttpClient User Discussion
> Subject: Re: ExceptionInInitializerError Error as soon as I Run
> 
> Hi Graeme,
> 
> > I have copied the tutorial here:
> > http://jakarta.apache.org/commons/httpclient/tutorial.html
> > So I know there are no errors in my code and I am sure I have all the
> > dependencies in the classpath but I still get these errors as soon as 
I 
> run
> > it:
> > 
> > Exception in thread "main" java.lang.ExceptionInInitializerError
> >         at HttpClientTutorial.main(HttpClientTutorial.java:13)
> > [...]
> > Caused by: java.lang.ClassNotFoundException:
> > org.apache.commons.logging.impl.Log
> > FactoryImpl
> 
> It looks like you are missing commons-logging.
> 
> 1) verify the dependencies in the classpath again:
> http://jakarta.apache.org/commons/httpclient/dependencies.html
> 
> 2) verify the logging configuration:
> http://jakarta.apache.org/commons/httpclient/logging.html
> 
> hope that helps,
>   Roland
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 


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


RE: ExceptionInInitializerError Error as soon as I Run

Posted by Graeme <co...@hotmail.com>.
Thanks for that
I take it I am right in putting the commons-logging here:
C:\Program Files\Java\jdk1.5.0_04\classpath\org\apache\commons\logging
Is that's how its suppose to look like. In the Logging folder are files like
LogConfigurationException and LogFactory for example and the folder impl

I don't quite understand the configuring. Since the Tutorial doesn't go into
that so I am not entirely sure what I am suppose to do I am not even sure
what file I am suppose to edit in the common-logging.


-----Original Message-----
From: Roland Weber [mailto:ROLWEBER@de.ibm.com] 
Sent: 12 September 2005 06:49
To: HttpClient User Discussion
Subject: Re: ExceptionInInitializerError Error as soon as I Run

Hi Graeme,

> I have copied the tutorial here:
> http://jakarta.apache.org/commons/httpclient/tutorial.html
> So I know there are no errors in my code and I am sure I have all the
> dependencies in the classpath but I still get these errors as soon as I 
run
> it:
> 
> Exception in thread "main" java.lang.ExceptionInInitializerError
>         at HttpClientTutorial.main(HttpClientTutorial.java:13)
> [...]
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.logging.impl.Log
> FactoryImpl

It looks like you are missing commons-logging.

1) verify the dependencies in the classpath again:
http://jakarta.apache.org/commons/httpclient/dependencies.html

2) verify the logging configuration:
http://jakarta.apache.org/commons/httpclient/logging.html

hope that helps,
  Roland


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


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


Re: ExceptionInInitializerError Error as soon as I Run

Posted by Roland Weber <RO...@de.ibm.com>.
Hi Graeme,

> I have copied the tutorial here:
> http://jakarta.apache.org/commons/httpclient/tutorial.html
> So I know there are no errors in my code and I am sure I have all the
> dependencies in the classpath but I still get these errors as soon as I 
run
> it:
> 
> Exception in thread "main" java.lang.ExceptionInInitializerError
>         at HttpClientTutorial.main(HttpClientTutorial.java:13)
> [...]
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.logging.impl.Log
> FactoryImpl

It looks like you are missing commons-logging.

1) verify the dependencies in the classpath again:
http://jakarta.apache.org/commons/httpclient/dependencies.html

2) verify the logging configuration:
http://jakarta.apache.org/commons/httpclient/logging.html

hope that helps,
  Roland


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