[英]Lookup a EJB Bean using JNDI
I trying inject a EJB into my class using a InitialContext (JNDI). 我尝试使用InitialContext(JNDI)将EJB注入类中。 For this i use a Netbeans insert code mechanism:
为此,我使用Netbeans插入代码机制:
after that Netbeans know witch injection have to use. 之后,Netbeans知道必须使用巫婆注射液。 @EJB annotation or JNDI Lookup.
@EJB批注或JNDI查找。 In my Example i have a simple, not managed class and what i want to do is inject a EJB Bean using JNDI.
在我的示例中,我有一个简单的而不是托管的类,我想做的是使用JNDI注入EJB Bean。 So Netbeans generate code for me as bellow:
因此,Netbeans为我生成了以下代码:
problem is that. 问题是。 When Netbeans generate code for me.
当Netbeans为我生成代码时。 He change a web.xml file and add there ejb-local-ref node:
他更改了一个web.xml文件,并在其中添加了ejb-local-ref节点:
and when i trying a turn on my web application. 当我尝试打开我的Web应用程序时。 I run glasfish and i always get following error:
我运行glasfish,总是出现以下错误:
Exception while deploying the app [mavenproject1-ear] : Error: Unresolved <ejb-link>: mavenproject1-ejb-1.0-SNAPSHOT#LanguagesFacade
i really dont know what to do. 我真的不知道该怎么办。 Can someone help with this issue.
有人可以解决这个问题吗? I will greatful for help.
我将竭诚为您服务。
Just remove the <ejb-local-ref>
all together. 只需一起删除
<ejb-local-ref>
。 It's defined for dependency injection and this is not your case here since you use JNDI to lookup the bean and set it in langaugeFacade variable. 它是为依赖项注入定义的,这里不是您的情况,因为您使用JNDI查找bean并将其设置在langaugeFacade变量中。 Just remove it and things will be fine.
只要删除它,一切都会好起来的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.