Using Jersey-spring with Spring 4.0 Using Jersey-spring with Spring 4.0 spring spring

Using Jersey-spring with Spring 4.0


I have started using Jersey 2.7 and Spring 4.0.x recently in a project. I have setup a context hierarchy to inject beans, so far, I have discovered only one limitiation but that does not seem relate to Spring 4 but rather to the module itself or the HK2 Spring Bridge.

To give more insight about my use. I have a XJC/JAXB-backed which is consumed by a common service, repository and exposed through JAX-WS, and now hopefully through JAX-RS.

The multi-context stuff works now with @Autowiredwith 2.8-SNAPSHOT. I have applied my changes and the 2.8-SNAPSHOT to 2.7. Here is the diff.

Edit (Michael-O; 2014-10-17): Here is a modified Spring module based off 2.11 with multi-context support.


Not an answer to original question, just related information

This may be a little premature, but the new Major 3.0 version of Jersey will be using Spring 4, in the new jersey-spring4 module. The new Major version will be built with Java 8. Though a new Major version will be released, the 2.x line will still be actively developed to keep support for Java 7

I'll update this post once 3.0 has been release.

For anyone interested, you can see this mailing list to see what the Jersey team has to say about the new 3.x line.


Not sure if you came across any issues but I currently face one. It is described in other thread.

Simply, using jersey-spring3 2.12 and spring 4.1.0.RELEASE in one maven project leads to following class incompatibility:

2014-09-14 01:15:44.175:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.server.handler.HandlerCollection@696db620[org.eclipse.jetty.server.handler.ContextHandlerCollection@27abb6ca[o.e.j.m.p.JettyWebAppContext@737d100a{/,file:/C:/Users/Josef/Workspace/TransitCenter/src/main/webapp/,STARTING}{file:/C:/Users/Josef/Workspace/TransitCenter/src/main/webapp/}], org.eclipse.jetty.server.handler.DefaultHandler@6968c1d6, org.eclipse.jetty.server.handler.RequestLogHandler@7d986d83]: java.lang.NoSuchMethodError: org.springframework.beans.factory.support.DefaultListableBeanFactory.getDependencyComparator()Ljava/util/Comparator;java.lang.NoSuchMethodError: org.springframework.beans.factory.support.DefaultListableBeanFactory.getDependencyComparator()Ljava/util/Comparator;        at org.springframework.context.annotation.AnnotationConfigUtils.registerAnnotationConfigProcessors(AnnotationConfigUtils.java:136)