0

I have created a Dynamic Web Project in Eclipse 3.6.1(Helios). I have added JAR files to the build path for this project and they all worked perfectly fine. However, Jsoup is one JAR file that is not being recognized. Whenever I attempt to run my Servlet it my Dynamic Web Project, I get the error in the server logs stating java.lang.NoClassDefFoundError: org/jsoup/Jsoup. Upon further inspection in the Class File Editor, I see the message

The JAR file /Users/ongozahcomputer/Downloads/jsoup-1.8.2.jar has no source attachment. You can attach the source by clicking Attach Source below: "

I have configured the build path of the package in which all my files are contained, hit add external JARs and added jsoup-1.8.2.jar. It is appearing in the build path. I also, upon other user's suggestions, added jsoup-1.8.2.jar to the WEB-INF/lib folder of my project. I am really stumped as to why it isn't being recognized and any help would be greatly appreciated. Thanks!

This is the console output:

WARNING: StandardWrapperValve[server.HelloServlet2]: PWC1406: Servlet.service() for servlet server.HelloServlet2 threw exception
java.lang.NoClassDefFoundError: org/jsoup/Jsoup
    at server.HelloServlet2.doGet(HelloServlet2.java:149)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:637)
Karthik
  • 4,950
  • 6
  • 35
  • 65
Alex Golding
  • 55
  • 1
  • 5
  • Right click on project > properties >Java Build Path >Order and Export [Tab] > check whether jsoup jar is ticked.If not tick it > Clean > Build > Run. – Iamat8 Jul 30 '15 at 12:56
  • [Eclipse - add .jar to Dynamic Web Project](http://stackoverflow.com/questions/11652431/eclipse-add-jar-to-dynamic-web-project) -> especially [this answer](http://stackoverflow.com/a/15173716/1393766). – Pshemo Jul 30 '15 at 13:33
  • Also [Adding 3rd party jars to WEB-INF/lib automatically using Eclipse/Tomcat](http://stackoverflow.com/a/5467530/1393766) – Pshemo Jul 30 '15 at 13:45

2 Answers2

1

You have added the jar files for compiling your dynamic web project. The same should be done while executing your application. Right click on your dynamic web project and click run As and Run configurations. Click the classpath and check the jar file is added there or not. If not, Add it to the classpath this will referred while executing the dynamic web application.

Hope it helps!

Shriram
  • 4,343
  • 8
  • 37
  • 64
0

Try adding the jars to 1. WEB-INF/lib folder. 2. Tomcat/lib folder.

Clean the server, Restart it, and Run the application.

This worked for me.