I am trying to follow this post's upvoted answer: Best practice for REST token-based authentication with JAX-RS and Jersey
I'm using the CDI approach and in my filter i have the definition:
@Inject
@AuthenticatedUser
Event<String> userAuthenticatedEvent;
But, when I run tomcat 7, I get the following error:
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=Event<String>,parent=AuthenticationFilter,qualifiers={@com.wink.rest.security.annotation.AuthenticatedUser()},position=-1,optional=false,self=false,unqualified=null,567185196)
at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:75)
at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:945)
at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:979)
at org.glassfish.jersey.ext.cdi1x.internal.AbstractCdiBeanHk2Factory$2.getInstance(AbstractCdiBeanHk2Factory.java:142)
at org.glassfish.jersey.ext.cdi1x.internal.AbstractCdiBeanHk2Factory._provide(AbstractCdiBeanHk2Factory.java:91)
at org.glassfish.jersey.ext.cdi1x.internal.GenericCdiBeanHk2Factory.provide(GenericCdiBeanHk2Factory.java:63)
I have tried everything I found on google and stackoverflow to try to resolve this, but none of the solutions worked. So now I'm not sure what else to do. Anyone have any advice?
After struggling with the same exact issue I found a solution to that. I switched from TomCat to Glassfish and updated maven dependencies to match the ones from official Jersey 2 documentation. After that it worked like magic.