簡體   English   中英

無狀態CDI托管bean

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM