users@jersey.java.net

[Jersey] Missing dependency for field when trying to inject a custom context with a Jersey

From: Michael Elman <tarlog_at_gmail.com>
Date: Mon, 12 Dec 2011 00:30:52 -0800 (PST)

have a custom context:

public class MyContext {
    public String doSomething() {...}
}

I have created a context resolver:

@Provider
public class MyContextResolver implements ContextResolver<MyContext> {

     public MyContext getContext(Class<?> type) {
         return new MyContext();
     }
}

Now in the resource I try to inject it:

@Path("/")
public class MyResource {

    @Context MyContext context;

}

And I get the following error:

SEVERE: Missing dependency for field: com.something.MyContext
com.something.MyResource.context

The same code works fine with Apache Wink 1.1.3, but fails with Jersey 1.10.

Any ideas will be appreciated.

--
View this message in context: http://jersey.576304.n2.nabble.com/Missing-dependency-for-field-when-trying-to-inject-a-custom-context-with-a-Jersey-tp7085381p7085381.html
Sent from the Jersey mailing list archive at Nabble.com.