Weblogic 10.3.5和EJB 3 JNDI名称

twe*_*sat 2 jndi weblogic11g ejb-3.0

有人能告诉我在哪里可以找到EJB 3的默认JNDI命名信息吗?

Weblogic是否使用像Glassfish这样的可移植JNDI名称?

我是否可以(使用Glassfish)找到使用JNDI名称的EJB部署的痕迹?

例如 :

  • 只有@Remote的接口(服务)
  • 只有@Stateless实现接口的bean(ServiceImpl)
  • 打包在.ear文件中的所有内容(service-application-1.0)

在Weblogic上部署时,我看到的唯一JNDI引用是:

service-application-1.0service-application-1.0_jarServiceImpl_Home
Run Code Online (Sandbox Code Playgroud)

但我不能在上下文查找中使用该名称.如果我做

Service myService = (Service) context.lookup("service-application-1.0service-application-1.0_jarServiceImpl_Home");
Run Code Online (Sandbox Code Playgroud)

它给了我

Exception in thread "main" java.lang.ClassCastException: weblogic.ejb.container.internal.StatelessEJBHomeImpl_1035_WLStub cannot be cast to com.tuto.Service
at com.tuto.TestEjb.main(TestEjb.java:24)
Run Code Online (Sandbox Code Playgroud)

PS.有了Glassfish它给了我

Portable jndi names for .... : java:global/service-application-1.0/service-application-ejb-1.0/ServiceImpl
Run Code Online (Sandbox Code Playgroud)

Service myService = (Service) context.lookup("java:global/service-application-1.0/service-application-ejb-1.0/ServiceImpl");
Run Code Online (Sandbox Code Playgroud)

工作中.

Lan*_*Lan 5

遗憾的是,EJB 3.0没有指定标准JNDI命名,而是将其留给服务器供应商.您引用有关mappedName的WL文档是正确的:"如果指定此属性,则无状态会话Bean可能不可移植".mappedName属性的缺点是全局JNDI名称将默认为mappedName#FullyQualifiedRemoteInterface.由于mappedName是源代码中的注释,因此它使您的代码不可移植.首选方法是在特定于供应商的部署描述符中保留特定于供应商的行为,例如weblogic-ejb-jar.xml.这样,您还可以选择指定自己的自定义JNDI名称,而不使用预定格式作为mappedName#FullyQualifiedRemoteInterface.

EJB 3.1为在全局,应用程序和模块级别标准化JNDI名称做了一些努力.请参阅http://docs.oracle.com/cd/E19798-01/821-1841/girgn/index.html