![](/img/trans.png)
[英]Error casting context.lookup(…) returned object to ejb3 remote object interface
[英]EJB 3.0 - Context.Lookup Failed loading apropriate EJB Beans
我正在研究EJB應用程序,我正在嘗試使用查找方法,但它在運行時失敗,
這是我的代碼和配置:
weblogic.xml中
<ejb-reference-description>
<ejb-ref-name>
RechercheClientSMBean
</ejb-ref-name>
<jndi-name>
*****-ejb/RechercheClientSMBean/local
</jndi-name>
</ejb-reference-description>
本地接口
@Local
public interface IRechercheClientFacade extends Facade {}
Bean實現
@Stateless(name="RechercheClientSMBean", mappedName="RechercheClientSMBean")
public class RechercheClientSMBean extends AbstractBean implements IRechercheClientFacade { }
web.xml中
<ejb-ref>
<ejb-ref-name>RechercheClientSMBean</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.*****.***.app.service.common.client.RechercheClientSMBean</home>
</ejb-ref>
Bean查找代碼
InitialContext ctx = new InitialContext();
iRechercheClientFacade= (IRechercheClientFacade)ctx.lookup("java:comp/env/RechercheClientSMBean");
它導致以下異常:
weblogic.deployment.EnvironmentException:
在應用程序模塊“pfi.war”中的ejb-ref或ejb-local-ref“RechercheClientSMBean”中聲明的ejb-link“RechercheClientSMBean”無法解析。 無法找到ejb-ref的目標EJB。 請確保鏈接正確。
我檢查了每個可能的配置,每個命名的可能性,但我不斷得到同樣的問題。
PS :項目分為多個模塊,查找方法是從web容器中完成的。
提前謝謝了。
您是否嘗試過以下操作:ctx.lookup(“java:comp / env / ejb / RechercheClientSMBean”);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.