users@jersey.java.net

Re: Jersey, Spring and UT

From: Jean Aurambault <aurambaj_at_yahoo-inc.com>
Date: Fri, 07 Mar 2008 14:06:48 +0100

Thank you for your help,

I finally figure out how to make the whole chain works with jetty. It
sounds good !

Jean.


Paul Sandoz wrote:
> Hi Jean,
>
> Jean Aurambault wrote:
>> Hil,
>>
>> I try to use spring with jersey 0.6 as described in Paul's article. I
>> would like to make Unit tests following this pattern: http call -->
>> jersey (use of spring to inject dao) --> dao (use of spring to manage
>> transaction and entity manager) --> hsqldb
>> Before using spring I was doing these tests with an in memory HTTP
>> server, here is an extract of the code:
>>
>> String[] packageNames = {...};
>> ResourceConfig rc = new PackagesResourceConfig(packageNames);
>>
>> HttpHandler handler =
>> ContainerFactory.createContainer(HttpHandler.class, rc);
>> server = HttpServerFactory.create(serverUrl + ":0/", handler);
>>
>> So it doesn't work anymore with spring.
>
> Sorry :-( i have not connected ComponentProvider initiation to work
> with the LW HTTP server or Grizzly. I will do that for 0.7.
>
> I think what i need to do is specify a ComponentProvider property
> whose value is an instance of a ComponentProvider and such a property
> can be added to the ResourceConfig instance.
>
>
>> I try to use jetty to run the whole web application but it seams
>> there is a problem when loading resources:
>> com.sun.ws.rest.api.container.ContainerException: The ResourceConfig
>> instance does not contain any root resource classes.
>>
>> Any advice on how to implement these tests? Have you some tips about
>> jetty resource loading (by the way I use maven)?
>>
>
>
> Maybe the following will help solve your problem with Jetty:
>
> https://jersey.dev.java.net/servlets/ReadMsg?list=users&msgNo=751
>
> ? However, i am not sure if you will need to do something slightly
> different for the spring configuration that is currently presented in
> the blog.
>
> Paul.
>