I am trying to inject UriInfo into a field so that I don't have to
inject it into every method.  This works correctly when I deploy the app
as a webapp, but when I try to test my services using
JAXRSServerFactoryBean it doesn't get injected and I get a NPE.
However, it will get injected if I change service to inject into each
method.  

 

Any ideas what might be going wrong here?

 

Here is the code snippet:

 

        final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();

        sf.setResourceClasses(MyService.class);

        sf.getInInterceptors().add(new LoggingInInterceptor());

        sf.getOutInterceptors().add(new LoggingOutInterceptor());

 

        sf.setResourceProvider(MyService.class,

            new SingletonResourceProvider(ctx.getBean("myService")));

        sf.setAddress(BASE_URI);

 

        sf.create();

 

and I have the folliwing field in MyService:

 

@Context UriInfo uriInfo;

 

Jason

Reply via email to