jQuery in Action, 2nd edition*
The moose likes Sockets and Internet Protocols and the fly likes HttpClient Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "HttpClient Exception" Watch "HttpClient Exception" New topic
Author

HttpClient Exception

Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Hi,

I have imported commons.httpclient.HttpClient jar file and added in my project. But still i am getting the below exception.

I have added the related jar files of logging, codec, Junit also in my project.


[2/21/12 18:32:09:168 IST] 00000095 servlet E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught exception created in one of the service methods of the servlet Test in application WebServiceEAR. Exception created : java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpClient
at Test.doGet(Test.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1455)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:793)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:444)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3622)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:927)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1566)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:175)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)



Could you please help me?


Thanks
Rajesh.B
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Hi,


Could someone please help on this?

Still i am strucking up with this.




Thanks,
Rajesh.B
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Apparently the jar file that contains the HttpClient class is not part of the runtime classpath.
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
Hi,


Thanks. Could you please lte me know how to add it in class path?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
If this is a web app then it should go into WEB-INF/lib.
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55


I have added the jar in Web-Inf/lib folder also. But still same getting the same exception.
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
I have added the below required jar files to my project.

commons-httpclient-3.1
commons-codec-1.4
commons-logging-1.1.1

And i am using IBM RAD 7.5 as my IDE. Now, i am getting the below exception if try to instantiate PostMethod of HttpClient.


[3/6/12 17:53:20:749 IST] 0000002c servlet E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught exception created in one of the service methods of the servlet Test in application WebServiceEAR. Exception created : java.lang.NoClassDefFoundError: org.apache.commons.codec.DecoderException
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java: 72)
at java.lang.J9VMInternals.initialize(J9VMInternals.j ava:134)
at org.apache.commons.httpclient.HttpMethodBase.<init >(HttpMethodBase.java:217)
at org.apache.commons.httpclient.methods.EntityEnclos ingMethod.<init>(EntityEnclosingMethod.java:118)
at org.apache.commons.httpclient.methods.PostMethod.< init>(PostMethod.java:105)
at Test.doGet(Test.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:718)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.ser vice(ServletWrapper.java:1455)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.han dleRequest(ServletWrapper.java:793)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.han dleRequest(ServletWrapper.java:444)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl .handleRequest(ServletWrapperImpl.java:175)
at com.ibm.ws.webcontainer.webapp.WebApp.handleReques t(WebApp.java:3622)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequ est(WebGroup.java:276)
at com.ibm.ws.webcontainer.WebContainer.handleRequest (WebContainer.java:927)
at com.ibm.ws.webcontainer.WSWebContainer.handleReque st(WSWebContainer.java:1566)
at com.ibm.ws.webcontainer.channel.WCChannelLink.read y(WCChannelLink.java:175)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLi nk.handleDiscrimination(HttpInboundLink.java:455)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLi nk.handleNewInformation(HttpInboundLink.java:384)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLi nk.ready(HttpInboundLink.java:272)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialRe adCallback.sendToDiscriminators(NewConnectionIniti alReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialRe adCallback.complete(NewConnectionInitialReadCallba ck.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListe ner.futureCompleted(AioReadCompletionListener.java :165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallbac k(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletion Actions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture .java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHand ler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingL oop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler .java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.j ava:1527)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.DecoderException
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:419)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtC lassLoader.java:150)
at java.lang.ClassLoader.loadClass(ClassLoader.java:6 43)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtC lassLoader.java:90)
at java.lang.ClassLoader.loadClass(ClassLoader.java:6 09)


Could someone please help me to resolve this?

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
What do you mean by "to my project"? As I said, the libs must be part of the runtime classpath, which has nothing to do with your IDE, and everything to do with the server you're using.
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55
I have added the required jar files in my library. But still getting the same error.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Do these required JAR files include the JAR files of Apache Commons Logging and Apache Commons Codec, as well as the dependencies of these two libraries? Because the README.txt of HttpClient mentions that it needs these two libraries as well as the HttpCore library. The latter has no dependencies.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rajesh Balu
Ranch Hand

Joined: Nov 07, 2011
Posts: 55

I have added the below list of Jar files.

commons-httpclient-3.1
commons-codec-1.2
commons-logging-1.1.1


Please let me know if i need to add any more jar files.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpClient Exception
 
Similar Threads
null retrieved from env-entry resource
JunitEE Problem
Getting error when migrated the was 5.1 to 6.1
html:select giving exception
Upload Excel using IO and servlet