1
我有一個JAXRS提供商:JavaEE的CDI和注入@Provider JAXRS給UnsatisfiedDependencyException
@Provider
@Priority(Priorities.AUTHENTICATION)
public class AuthFilter implements ContainerRequestFilter {
@Inject
private AuthSecurityContext authSecurityContext;
// ...
}
而且我的SecurityContext實現:
@RequestScoped
public class AuthSecurityContext implements SecurityContext {
// ...
}
我使用的GlassFish作爲我的容器,但它扔以下例外情況:
2017-06-26T01:04:49.139+0100|Warning: The following warnings have been detected: WARNING: Unknown HK2 failure detected:
MultiException stack 1 of 1
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=AuthSecurityContext,parent=AuthFilter,qualifiers={},position=-1,optional=false,self=false,unqualified=null,2049394753)
我的其他豆類正在被發現和注入埠t @Provider
中的這一項不起作用,我錯過了什麼?
您正在使用哪臺服務器? – Rouliboy
確保您使用的是javax.enterprise.context.RequestScoped而不是javax.faces.bean.RequestScoped – maress
@Rouliboy我使用Glassfish 4.1作爲容器。 – Neilos