29

According to you what are the risks of using Spring 4 with the jersey-spring3 integration module?

I have tried to use Spring 4.0 with the jersey spring example and the example still works but i'm unable to identify risks linked to this usage.

guli
  • 1,183
  • 1
  • 9
  • 19
  • What do you mean by risks? We are using Spring 4.x along with Jersey 2.5.x and so far we have not run into any issue. Do you have anything particular in mind? – pgiecek Feb 17 '14 at 07:01
  • 1
    I didn't have anything in mind. I would know if someone has knowledge about possible issues that can be caused by using Spring4.x instead of 3.x with jersey-spring3 that seems to be designed to handle Spring 3.X and not 4.x. Thanks. – guli Feb 18 '14 at 10:20
  • Have you gotten any further experience with this, guli? – Martin Lie Apr 07 '14 at 12:38
  • i make a few little tests and i didn't see any issue, but i'm not sure... perhaps one day somewhere i will get an error... Sorry – guli Apr 07 '14 at 15:48

3 Answers3

10

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.

Michael-O
  • 18,123
  • 6
  • 55
  • 121
  • @Michael-O- Thanks for the help. What I am understanding is I have to prepare a jar applying your patch to make jersey work with spring 4. For that I downloaded Jersey 2.11. Imported `jersey-spring3` project & applied your path that is shared on github (Replaced all classes from patch). & Try to build a jar. But it still gives me same error `ServletContext must not be null`. Let me know if I am following wrong wrong steps. Thanks – hemu Oct 17 '14 at 16:10
  • @hemu, can you share the entire stacktrace on pastebin or alike? I have a few custom Spring 4/Jersey components which work flawlessly. Some bit must be missing in your setup. Another issue, I have this running on Tomcat 6 but it shouldn't make difference. – Michael-O Oct 17 '14 at 17:20
  • @Michael-O - Please see the full stacktrace at [this](http://pastebin.com/ns3SnUGN) link – hemu Oct 20 '14 at 07:56
  • @hemu, I'll need some time to check that because I do not rely on the test unit tests. – Michael-O Oct 21 '14 at 11:57
5

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.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
3

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@696
db620[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/w
ebapp/}], org.eclipse.jetty.server.handler.DefaultHandler@6968c1d6, org.eclipse.jetty.server.handler.RequestLogHandler@7
d986d83]: java.lang.NoSuchMethodError: org.springframework.beans.factory.support.DefaultListableBeanFactory.getDependenc
yComparator()Ljava/util/Comparator;
java.lang.NoSuchMethodError: org.springframework.beans.factory.support.DefaultListableBeanFactory.getDependencyComparato
r()Ljava/util/Comparator;
        at org.springframework.context.annotation.AnnotationConfigUtils.registerAnnotationConfigProcessors(AnnotationCon
figUtils.java:136)
Community
  • 1
  • 1
jspetrak
  • 103
  • 1
  • 9
  • 2
    I'm not sure but i think you need to ignore jersey-spring3 dependencies to spring in order to be sure to use Spring 4. – guli Sep 14 '14 at 00:31
  • 6
    That was true in the end. Exclusion of spring-core, spring-web and spring-beans from jersey-spring3. – jspetrak Sep 14 '14 at 20:18