[英]Stateless CDI Managed bean
当我部署一个具有jsf 2.2的WAR文件时,我无法在我的jboss上找到一个JNDI中的bean。我得到以下异常。 任何人都知道为什么会这样吗? (bean在JNDI中,我看到Jboss绑定它,我尝试了各种查找路径)
Deployment "vfs:///C:/jboss-6.1.0.Final/server/all/deploy/web.war" is in error due to the following reason(s): java.lang.RuntimeException: Could not resolve @EJB reference: [EJB Reference: beanInterface 'se.questify.services.entities.ExamServiceBase', beanName 'null', mappedName 'null', lookupName
'null', owning unit 'AbstractVFSDeploymentContext@1298976756{vfs:///C:/jboss-6.1.0.Final/server/all/deploy/web.war}'] for environment entry: env/ExamService/local in unit AbstractVFSDeploymentContext@1298976756{vfs:///C:/jboss-6.1.0.Final/server/all/deploy/web.war}
在ejb.jar的部署上的Jboss堆栈
INFO [org.jboss.ejb3.nointerface.impl.jndi.AbstractNoInterfaceViewBinder] Binding the following entry in Global JNDI for bean:ExamServiceBase
ExamServiceBase/no-interface -> EJB3.1 no-interface view
EJB
@Stateless
@Named("examServiceBase")
public class ExamServiceBase{
public String getHello(){
return "hello";
}
}
JSF代码
<h:body>
<h1>JSF 2 Demo</h1>
<h:form>
<h:outputLabel value="#{examServiceBase.hello}" />
</h:form>
</h:body>
你不能两者兼得。 你不能同时拥有@Named
和@Stateless
,它们是互斥的。 来自Oracle:
如果...它满足以下所有条件,则顶级java类是托管bean:
- 它没有使用EJB组件定义注释或在ejb-jar.xml中声明为EJB bean类
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.