Glassfish WELD-001408:HttpSession类型的未满足依赖性
在我的JSF项目中,我有一个@SessionScoped bean(现在臭名昭著):Glassfish WELD-001408:HttpSession类型的未满足依赖性,glassfish,cdi,jboss-weld,Glassfish,Cdi,Jboss Weld,在我的JSF项目中,我有一个@SessionScoped bean(现在臭名昭著): @Named(value = "appointmentFormBean") @SessionScoped public class AppointmentFormBean implements Serializable { @Inject private transient AppointmentService service; public AppointmentFormBean() {
@Named(value = "appointmentFormBean")
@SessionScoped
public class AppointmentFormBean implements Serializable {
@Inject
private transient AppointmentService service;
public AppointmentFormBean() {
bookedAlready = new ArrayList<>();
types = new LinkedHashMap<>(4, (float) 0.75);
}
public AppointmentService getService() {
return service;
}
public void setService(AppointmentService service) {
this.service = service;
}
...
//other fields, setters and getters
}
这些是EJB(简而言之):
在构建过程中(否则会成功),我得到以下警告:
INFO: WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.jglue.cdiunit.in...receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
在运行期间,我遇到以下异常:
Severe: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type HttpSession with qualifiers @CdiUnitServlet
at injection point [BackedAnnotatedField] @Inject @CdiUnitServlet private org.jglue.cdiunit.ContextController.session
at org.jglue.cdiunit.ContextController.session(ContextController.java:0)
WELD-001475: The following beans match by type, but none have matching qualifiers:
- WELD%AbstractSyntheticBean%WEB-INF/lib/cdi-unit-3.1.3%HttpSession
如果您愿意,我可以打印整个堆栈。在浏览stackoverflow和web时,我发现了许多可能出错的理论,但并没有一个适用的解决方案。有人认为错误可能是由于Glassfish与Weld的集成,Glassfish与JavaSE8 20之前的集成(我使用的是jdk-8u65-linux-x64.rpm),但后来我看到人们在WildFly上运行项目时遇到类似的问题
所以我叫你去营救:-)
ps我的项目可以在这里找到:这个问题可以在数小时的调查后解决。感谢BrynCooke@此链接: 问题是我的cdi单元maven依赖性,它必须是测试范围。我这样做了,并且从我正在使用的cdi单元工件中排除了weld se core,并将后者作为一个单独的依赖项添加到了一个单独的组件中 这是pom.xml中的修复部分:
<dependency>
<groupId>org.jglue.cdi-unit</groupId>
<artifactId>cdi-unit</artifactId>
<version>3.1.3</version>
<exclusions>
<exclusion>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>2.2.2.Final</version>
<scope>test</scope>
</dependency>
org.jglue.cdi-unit
cdi单元
3.1.3
org.jboss.weld.se
焊接se型芯
试验
org.jboss.weld.se
焊接se型芯
2.2.2.最终版本
测试
Severe: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type HttpSession with qualifiers @CdiUnitServlet
at injection point [BackedAnnotatedField] @Inject @CdiUnitServlet private org.jglue.cdiunit.ContextController.session
at org.jglue.cdiunit.ContextController.session(ContextController.java:0)
WELD-001475: The following beans match by type, but none have matching qualifiers:
- WELD%AbstractSyntheticBean%WEB-INF/lib/cdi-unit-3.1.3%HttpSession
<dependency>
<groupId>org.jglue.cdi-unit</groupId>
<artifactId>cdi-unit</artifactId>
<version>3.1.3</version>
<exclusions>
<exclusion>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>2.2.2.Final</version>
<scope>test</scope>
</dependency>