Re: [Jersey] Re: Spring framework support for Jersey 2

  • From: Miroslav Fuksa <miroslav.fuksa@...>
  • To: users@...
  • Cc: Marko Asplund <marko.asplund@...>, dev@...
  • Subject: Re: [Jersey] Re: Spring framework support for Jersey 2
  • Date: Thu, 04 Jul 2013 17:45:03 +0200

Hi Marko,

sorry for a late answer.

I have checked your updated pull request. Thanks.

It is fine that you have written an email prior to some further development. There is a news, that HK2 should soon support Spring integration which could simplify the development on the Jersey side. There will still be needed some work on Jersey to integrate with Spring but lot of problems could be already solved by HK2. We will have to check the status and investigate some documentation. Based on this, I would suggest that you don't continue with the development now and we will see which functionality HK2 will offer to us. In the meantime you can sign the OCA (Oracle Contributor Agreement). This is needed in order to contribute to Jersey.

See this link:

This is summary of requirements from injection perspective:

1. inject Spring beans into jersey JAX-RS resource classes and providers (filters, interceptors, ...)
    - injection by @Autowire
    - injection by @Inject
2. allow JAX-RS resource classes and providers to be managed by Spring instead of Jersey
3. inject Jersey injections into the Spring managed JAX-RS resource classes and providers (these mentioned in point 2)
- inject by @Inject and @Context (this is needed as resource classes must still be compliant with JAX-RS spec which allows injection of JAX-RS providers be these annotations). This means Spring managed beans will support these injections.
- and of course allow standard Spring injection for these Spring managed beans with @Autowire, definition by xml (applicationContext.xml), @Inject

We will also need to migrate Jersey 1 samples as you have written.

I have some more comments below....


On 06/29/2013 11:47 PM, Marko Asplund wrote:

I was finally able to find some time to work with Jersey 2 Spring integration again.

Now, the prototype implementation supports the following features:
- inject Spring beans into Jersey managed JAX-RS resource classes
yes - point 1.
- allow JAX-RS resource classes to be managed by Spring instead of Jersey
yes - point 2.
- support singleton and request scopes for both of the above
yes, the scopes should be supported. This means when you annotate the resource or provider with @RequestScope, @Singleton or @PerLookup, the scoping should work correctly for spring managed resources and providers as it currently works for jersey managed ones. I am now not exactly sure how to managed spring definition of scopes but probably this should be still managed by spring in the spring way but might be overriden by Jersey scope annotations. But I am not sure about this point.

I haven't yet ported the Jersey 1 Spring integration test cases, but I could try to look into this later.

Before starting to work on the test cases, would it be possible for you, or some other person in the Jersey development team, to take a look at the integration prototype? Just to see if it meets the functional requirements and that the design is viable?

The code can be found here:

best regards,


Re: [Jersey] Re: Spring framework support for Jersey 2

Miroslav Fuksa 07/04/2013

Re: [Jersey] Re: Spring framework support for Jersey 2

cowwoc 07/04/2013

Re: [Jersey] Re: Spring framework support for Jersey 2

Marko Asplund 07/06/2013
Terms of Use; Privacy Policy; Copyright ©2013-2017 (revision 20160708.bf2ac18)
Please Confirm