views:

1253

answers:

1

I've deployed Jersey on Tomcat and everything works perfectly (when I use the com.sun.jersey.spi.container.servlet.ServletContainer), but as soon as I change it to the com.sun.jersey.spi.spring.container.servlet.SpringServlet (according to all the tutorials I can find), I get a nasty exception:

Apr 19, 2009 5:07:35 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet ServletAdaptor as unavailable
Apr 19, 2009 5:07:35 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /myservice threw load() exception
java.lang.ClassNotFoundException: com.sun.jersey.spi.service.ComponentProvider

Any idea what package/distribution it can reside? What am I missing?

May be I don't need it at all. I'm trying to make sure that when my resource class is loaded it'll be Autowired and initialized with the rest of the Beans it depends on. Can it be done differently?

Thanks.

A: 

The com.sun.jersey.spi.service.ComponentProvider interface is part of the jersey-core JAR so it's odd that you're getting that exception.

Make sure you're using the same version of the jersey libraries together (i.e. you're using Jersey 1.0.1 libraries, not mixing 1.0 and 1.0.1 as the Spring classes got renamed between those two releases).

Also ensure you have a ContextLoaderListener in your web.xml like so:

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
safetydan
I've removed all the conflicting version JARs and readded only from 1.0.3 - the exception disappeared. As well my JSON functionality was reduced to bare minimum, but, I guess, is a separate issue.
IgorM
JSON support changed recently in Jersey. Make sure you're configured to use Jackson for JSON support and have the required libraries.
safetydan