3

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.

4

1 回答 1

1

com.sun.jersey.spi.service.ComponentProvider 接口是 jersey-core JAR 的一部分,所以奇怪的是你得到了那个异常。

确保一起使用相同版本的 jersey 库(即,您使用的是 Jersey 1.0.1 库,而不是混合 1.0 和 1.0.1,因为 Spring 类在这两个版本之间被重命名)。

还要确保您的 web.xml 中有一个 ContextLoaderListener,如下所示:

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
于 2009-04-19T22:38:17.463 回答