How to use CDI events in Java Jersey?

I am trying to execute this answer with a saved answer: Best authentication practice based on REST tokens with JAX-RS and Jersey

I use the CDI approach, and in my filter I have a definition:

@Inject
@AuthenticatedUser
Event<String> userAuthenticatedEvent;

But, when I start 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 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 tips?

+4
source share
1 answer

. TomCat Glassfish maven, , 2. .

+1

All Articles