You may feel this is a duplicated question, but none of the questions with the same title solve my problems. I am using Jersey 2.0 creating a RESTful web service in Eclipse,
For me, the fix was doing this:
Right click on Project -> Properties -> Java Build Path -> Libraries ->
Add Library... -> Server Runtime -> Apache Tomcat v7.0 -> Finish
Another step i did was to import stuff in Maven but it wasnt neccessary as it is running fine without it too.
But here it is if it helps anyone
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2.1-b03</version>
<scope>provided</scope>
</dependency>
putting servlet jars in WEB-INF/lib just did things more complicated as the Exception Message got more complicated and irrelevant
EDIT: oh what also does help is to do an Update Project on your Maven Project.
Add Jersey library to the build path under library
Wait, you said you have a Jersey library called jersey
, did you create a User Library
and name it jersey
? If so, try to copy your jersey jar files into WebContent -> WEB-INF -> lib.
I guess this has already been answered, but just wanted to add an extra tip.
For web projects in Eclipse, it is almost always advisable to manage dependencies with Maven. Use a Maven plugin like m2e. Once you add a dependency to your Maven project, it should automatically deploy those libraries to WEB-INF/lib. If it does not (for whatever reasons), you can explicit do so:
This should add the libraries to WEB-INF/lib, although you'd still not see them in the Project Explorer view. But your ClassNotFoundException should go away now.