0

I am getting this exception and I have been googling around to figure out what i have been missing. So far, I have been through

java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

The problem look similar but perhaps I am unable to figure out what is my mistake. Here is my web.xml

![<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>com.vogella.jersey.first</display-name>
 <servlet>
    <servlet-name>Jersey REST Service</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
     <!-- Register resources and providers under com.vogella.jersey.first package. -->
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>com.vogella.jersey.first</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Jersey REST Service</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>
</web-app>

Libraries Screen Shot

Updated Libraries Screen Shot

I have attached my libraries hierarchy as well. I am sure its pretty dumb thing which i am unable to figure out :(

Community
  • 1
  • 1
Em Ae
  • 8,167
  • 27
  • 95
  • 162
  • Did you add JAX RS API to your pom file? – David Oct 08 '14 at 01:52
  • its there, see i posted an updated screen shot – Em Ae Oct 08 '14 at 02:39
  • 1
    Ok. Did you check that the libs are copied to your /WEB-INF/lib folder on your deployment target? And maybe this helps: http://stackoverflow.com/questions/22022114/org-glassfish-jersey-servlet-servletcontainer-classnotfoundexception – David Oct 08 '14 at 02:47
  • Thanks for the hing, what it turn out that eclipse wasn't exporting those libraries. I had to explicitly add all libraries via *Deployment Assembly* option in *Project > Properties > Deployement Assembly* How can i accept your suggestion as an answer ? – Em Ae Oct 08 '14 at 03:13

1 Answers1

0

Please not that Vogella uses Jersey 2.x

"In this tutorial Eclipse 4.4 (Luna), Java 1.6, Tomcat 6.0 and JAX-RS 2.0 (with Jersey 2.11) is used."

Do you use the right version of JAX-RS?

David
  • 3,388
  • 2
  • 21
  • 25