users@jersey.java.net

Can't get _at_Context Application be injected

From: Jörg Richter <jri_at_deepamehta.de>
Date: Wed, 2 Jun 2010 02:55:59 +0200

Hi,

When using the servlet init parameter javax.ws.rs.Application the Application instance is not injected into @Context Application annotated variables.

Neither into a class field:

        public class MyResource {
                @Context Application app;
                ...
        }

Nor into a constructor parameter:

        public MyResource(@Context Application app) {
                ...
        }

Nor into a resource method parameter:

        @GET
        public Response myResourceMethod(@Context Application app) {
                ...
        }

When Jersey instantiates the Application class an error is reported respectively:

        SEVERE: The following errors have been detected with resource and/or provider classes:
        
                SEVERE: Missing dependency for field: javax.ws.rs.core.Application MyResource.app

                SEVERE: Missing dependency for constructor public MyResource(javax.ws.rs.core.Application) at parameter index 0

                SEVERE: Missing dependency for method public Response MyResource.myResourceMethod(javax.ws.rs.core.Application) at parameter at index 0

The variable intended for being injected (app) remains null.

Injection of other context, e.g. @Context UriInfo works well.
Just @Context Application doesn't work (as described in JSR-311 specification, section 5.2.1).

Do (or understand) I something wrong?

Tested with Jersey 1.3-SNAPSHOT (May 27).

Cheers,
Jörg