无状态EJB实现了接口注入失败 [英] Stateless EJB implements interface injection failed
问题描述
Wildfly 8.2.0
我有一个无状态
EJB和界面。
@Local
@Stateless
public class Bean implements IBean {
...
}
@Local
public interface IBean {
...
}
但是我收到一个WELD错误。如果Bean没有实现该接口,则没有错误。根据 https://stackoverflow.com/a/13988450/2023524
和 https://blogs.oracle.com/arungupta/entry/what_s_new_in_ejb 应该没有错误。
错误:
WELD-001408:不符合类型Bean的依赖关系,默认
在注入点[BackedAnnotatedField] @Inject私人mypackage.anotherBean.bean
更新:
我尝试了所有可能的组合与本地
,但它没有帮助。只有当界面被删除时,没有错误。
@Stateless
public class Bean implements IBean {
...
}
@Local
public interface IBean {
...
}
// ************ *****************
@Stateless
public class Bean implements IBean {
...
}
public interface IBean {
...
}
// ************************* ***********
@Local
@Stateless
public class Bean implements IBean {
...
}
public interface IBean {
...
}
当您想使用EJB注入一个bean(使用 Wildfly 8.2.0 I have a But I get a WELD Error. If Bean doesn't implement the interface there is no errors. According to https://stackoverflow.com/a/13988450/2023524
and https://blogs.oracle.com/arungupta/entry/what_s_new_in_ejb there should be no error. Error: Update:
I've tried all possible combinations with
When you want to inject a bean whether by EJB (using 这篇关于无状态EJB实现了接口注入失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! @EJB
)或CDI(使用 @Inject
)容器声明一个带有接口类型的变量。在应用程序部署期间,由容器找到声明接口的具体实现。在你的例子中,问题不在于注释,而是注入声明的类型(
Bean
而不是 IBean
)。 / p> Stateless
EJB and an interface.@Local
@Stateless
public class Bean implements IBean{
...
}
@Local
public interface IBean {
...
}
WELD-001408: Unsatisfied dependencies for type Bean with qualifiers @Default
at injection point [BackedAnnotatedField] @Inject private mypackage.anotherBean.bean
Local
but it doesn't help. Only if interface is removed there is no error. @Stateless
public class Bean implements IBean{
...
}
@Local
public interface IBean {
...
}
//*****************************
@Stateless
public class Bean implements IBean{
...
}
public interface IBean {
...
}
//************************************
@Local
@Stateless
public class Bean implements IBean{
...
}
public interface IBean {
...
}
@EJB
) or CDI (using @Inject
) container you declare a variable with interface type. Concrete implementation of declared interface is found by a container during application deployment. In your example the problem is not with annotations but with a declared type being injected (Bean
instead of IBean
).