我和泽西岛一起尝试Atmosphere能够向用户广播消息。但是,根据对Jersey端点的请求,日志中会出现以下内容并导致ServletException。
SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Missing dependency for method public void org.apache.cxf.jaxrs.provider.JSONProvider.setMessageContext(org.apache.cxf.jaxrs.ext.MessageContext) at parameter at index 7
SEVERE: Missing dependency for field: private org.apache.cxf.jaxrs.ext.MessageContext org.apache.cxf.jaxrs.provider.RequestDispatcherProvider.mc
SEVERE: Missing dependency for method public void org.apache.cxf.jaxrs.provider.JAXBElementProvider.setMessageContext(org.apache.cxf.jaxrs.ext.MessageContext) at parameter at index 1
SEVERE: Missing dependency for field: private org.apache.cxf.jaxrs.ext.MessageContext org.apache.cxf.jaxrs.provider.MultipartProvider.mc
SEVERE: Missing dependency for method public void org.apache.cxf.jaxrs.provider.JAXBElementProvider.setMessageContext(org.apache.cxf.jaxrs.ext.MessageContext) at parameter at index 13
SEVERE: Missing dependency for field: private org.apache.cxf.jaxrs.ext.MessageContext org.apache.cxf.jaxrs.provider.FormEncodingProvider.mc
stacktrace的一部分:
SEVERE: Allocate exception for servlet AtmosphereServlet
javax.servlet.ServletException
at org.atmosphere.cpr.AtmosphereServlet.init(AtmosphereServlet.java:540)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
我正在使用Maven并添加了以下依赖项:
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-jersey</artifactId>
<version>0.6.3</version>
</dependency>
我错过了什么?谢谢!
答案 0 :(得分:6)
问题显然是应用程序中存在两种JAX-RS实现。这可以通过使Jersey仅扫描包含Rest类的包来解决,因此不知道其他JAX-RS实现。
<servlet>
<description>AtmosphereServlet</description>
<servlet-name>AtmosphereServlet</servlet-name>
<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
...
<init-param>
<param-name>com.sun.jersey.config.property.packages</ param-name>
<param-value>mypackage.with.the.rest.classes</param-value>
</init-param>
</servlet>
感谢Jersey邮件列表上的Paul Sandoz和Atmosphere邮件列表上的Jeanfrancois。
答案 1 :(得分:0)
据报道,在web.xml中降级web-app描述符版本可以帮助禁用本机(Jersey)扫描:http://cxf.apache.org/docs/jax-rs-deployment.html#JAX-RSDeployment-WebLogic
<!-- From: -->
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd">
</web-app>
<!-- To: -->
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
</web-app>