views:

38

answers:

2

The build of the project is succesfull, but when I go the the url I get the following error report:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error instantiating servlet class example.servlet.ScrapingServlet
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 java.lang.Thread.run(Thread.java:619)

root cause

java.lang.NoClassDefFoundError: org/apache/http/impl/client/DefaultHttpClient
 java.lang.Class.getDeclaredConstructors0(Native Method)
 java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
 java.lang.Class.getConstructor0(Class.java:2699)
 java.lang.Class.newInstance0(Class.java:326)
 java.lang.Class.newInstance(Class.java:308)
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 java.lang.Thread.run(Thread.java:619)

root cause

java.lang.ClassNotFoundException: org.apache.http.impl.client.DefaultHttpClient
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
 java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
 java.lang.Class.getDeclaredConstructors0(Native Method)
 java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
 java.lang.Class.getConstructor0(Class.java:2699)
 java.lang.Class.newInstance0(Class.java:326)
 java.lang.Class.newInstance(Class.java:308)
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 java.lang.Thread.run(Thread.java:619)

>note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
Apache Tomcat/6.0.14

And that is because I added this simple line to the code: DefaultHttpClient httpclient = new DefaultHttpClient();

What am I doing wrong?

+2  A: 

They key thing to look at in the stack trace is java.lang.ClassNotFoundException: org.apache.http.impl.client.DefaultHttpClient

It's telling you that it can't find org.apache.http.impl.client.DefaultHttpClient in the class path. Resolve that problem and life should get better.

Jim Blizard
A: 

You need to put the HttpClient libraries in /WEB-INF/lib, which is part of the default runtime classpath.

BalusC
thanks, I had to add a line for each JAR in the build.xml such that the libraries where copied to the /WEB-INF/lib
Derk
You're welcome.
BalusC