Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpClient Exception

 
Rajesh Balu
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


Could someone please help on this?

Still i am strucking up with this.




Thanks,
Rajesh.B
 
Tim Moores
Bartender
Posts: 2895
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently the jar file that contains the HttpClient class is not part of the runtime classpath.
 
Rajesh Balu
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


Thanks. Could you please lte me know how to add it in class path?
 
Tim Moores
Bartender
Posts: 2895
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is a web app then it should go into WEB-INF/lib.
 
Rajesh Balu
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I have added the jar in Web-Inf/lib folder also. But still same getting the same exception.
 
Rajesh Balu
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2895
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added the required jar files in my library. But still getting the same error.
 
Rob Spoor
Sheriff
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rajesh Balu
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic