users@jersey.java.net

[Jersey] Debugging _at_Context injection failure on Tomcat

From: <nbeyer_at_cerner.com>
Date: Wed, 2 Nov 2011 22:16:46 +0000 (GMT)

I'm using jersey 1.9.1 and getting some dependency injection failures
on the loading of resources via @Context. I've seen then when using
Grizzly in a unit test scenario, but I'm also experiencing it when
deploying to Tomcat 6.0.x. The confusing part is I have the exact same
resource with the same @Context ServletContext injection in two
different projects and one project loads fine and functions correctly,
but the other project fails to load.

Here's what the resource method looks like in both projects -

  @GET
  @Produces(MediaType.TEXT_HTML)
  public Response get(@Context ServletContext context) {
   # ...
  }

Here's the error reported when the resource is hit via a browser -
SEVERE: The following errors and warnings have been detected with
resource and/or provider classes:
  SEVERE: Missing dependency for method public
com.blah.resources.BlahResource.get(javax.servlet.SerlvetContext) at
parameter index 0

Any suggestions on how to debug this and find the difference between
the two projects?