在 Weblogic 10.xx 上使用 InitialContext 查找 EJB
您能告诉我如何在 Weblogic 上查找 EJB 吗?
我有以下 bean:
@Stateless
@EJB(name = "DataAccess", beanInterface = DataAccessLocal.class)
public class DataAccess implements DataAccessLocal {
...
}
我需要在其他类中使用这个 bean,该类不属于托管内容(只是简单的类),所以我想应该这样做:
DataAccessLocal dataAccess = DataAccessLocal.class.cast((new InitialContext()).lookup("%SOME_JNDI_NAME%"));
问题是在 Weblogic 的情况下应该将什么用作 %SOME_JNDI_NAME% 10.xx AS?
任何帮助将不胜感激。
Could you please tell me how to lookup EJB on Weblogic?
I have following bean:
@Stateless
@EJB(name = "DataAccess", beanInterface = DataAccessLocal.class)
public class DataAccess implements DataAccessLocal {
...
}
I need this bean in other class which is not part of managed content (just simple class), so I guess it should be done like this:
DataAccessLocal dataAccess = DataAccessLocal.class.cast((new InitialContext()).lookup("%SOME_JNDI_NAME%"));
The question is what should be used as %SOME_JNDI_NAME% in case of Weblogic 10.x.x AS?
Any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会将您的 EJB 类更新为如下所示:
从同一 EAR 中部署的类中查找 EJB(使用本地接口):
EJB 注入通常是首选,您可以按如下方式执行操作:
如果您尝试使用远程 EJB,那么您将需要使用远程接口和以下 JNDI 名称:
I would update your EJB class to look like this:
Looking up the EJB from a class deployed in the same EAR (using the local interface):
EJB injection is usually preferred, and you can do it as follows:
If you are trying to use the EJB remotely then you will need to use the remote interface and the following JNDI name: