5

I am trying Atmosphere together with Jersey to be able to broadcast messages to users. However on request to the Jersey endpoint, the following appears in the log and results in 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

Part of 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)

I am using Maven and have added the following dependency:

<dependency>
  <groupId>org.atmosphere</groupId>
  <artifactId>atmosphere-jersey</artifactId>
  <version>0.6.3</version>
</dependency>

What am I missing? Thanks!

Kristoffer
  • 1,633
  • 3
  • 19
  • 25

2 Answers2

6

The problem was apparently that two implementations of JAX-RS somehow existed in the application. This can be solved by making Jersey scan only the package containing the Rest classes and therefore be unaware of other JAX-RS implementations.

<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>

Thanks to Paul Sandoz on the Jersey mailing list and Jeanfrancois on the Atmosphere mailing list.

Kristoffer
  • 1,633
  • 3
  • 19
  • 25
  • Thanks, it worked perfectly in my case while Apache Tomcat was telling me "SEVERE: Missing dependency for method public void org.apache.cxf.jaxrs.provider.RequestDispatcherProvider.setMessageContext(org.apache.cxf.jaxrs.ext.MessageContext) at parameter at index 14" Just changed mypackage.with.the.rest.classes for the package where my REST was defined, and everything worked. Thanks a lot. – tremendows Mar 19 '13 at 14:48
0

It was reported that downgrading a web-app descriptor version in web.xml can help disable the native (Jersey) scanning: 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>
2787184
  • 3,749
  • 10
  • 47
  • 81