How to add JSR-311 dependency for Jersey Jax-RS maven project
jax-rs, jersey, maven
Solution
The problem is your JSR 311 API dependency is version 1.0, whereas Jersey 1.15 is a JSR 311 version 1.1 implementation. Compare http://jsr311.java.net/nonav/releases/1.0/javax/ws/rs/core/Response.Status.html and http://jsr311.java.net/nonav/releases/1.1/javax/ws/rs/core/Response.Status.html, and you will see that the latter implements the `ResponseType` interface, but the former does not.
You should be able to have the JSR 311 version 1.1.1 API class files on the build-time classpath by declaring something like this:
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
In fact, the jersey-core `pom.xml` already does this - the above is just the first dependency in http://repo1.maven.org/maven2/com/sun/jersey/jersey-core/1.15/jersey-core-1.15.pom.
In a container like Glassfish, you'd now be done, since the container would be responsible for providing the API classes for you at runtime (which is why the scope in jersey's own Maven POM is `provided`, not `compile`). However, for the Grizzly web container, it is likely you'll need to ensure that the API classes are available at runtime (by using the `<dependency>` declaration above, but changing `<scope>` from `provided` to `compile` will do this).
Problem
The following questions discusses the theory of the dependencies between Jersey and the JAX-RS specification: - JAX-RS in relation to Jersey and JSRs I was assuming that I could add the dependency: ``` <!-- javax.ws.rs.core e.g. Request --> <dependency> <groupId>javax.ws.rs</groupId> <artifactId>jsr311-api</artifactId> <version>1.0</version> </dependency> ``` to my API defining maven project and use Jersey/Grizzly for the implementation. ``` <jersey.version>1.15</jersey.version> <grizzly.version>2.2.20</grizzly.version> ``` Contrary to this assumption I got the following error message: ``` 15.02.2013 08:41:25 org.glassfish.grizzly.http.server.HttpServerFilter handleRead WARNUNG: Unexpected error java.lang.IncompatibleClassChangeError: Class javax.ws.rs.core.Response$Status does not implement the requested interface javax.ws.rs.core.Response$StatusType at com.sun.jersey.spi.container.ContainerResponse.getStatus(ContainerResponse.java:571) ``` What is the correct JAX-RS API dependency that should be used with Jersey 1.15? I'd like to do it in a way that the implementation could be replaced by any other JAX-RS compliant library.