Weblogic 10.3.5及更高版本EJB 3 JNDI名称 [英] Weblogic 10.3.5 & EJB 3 JNDI names

查看:116
本文介绍了Weblogic 10.3.5及更高版本EJB 3 JNDI名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Could someone tell me where I can find infos on the default JNDI naming for EJB 3 ?

Weblogic是否使用可移植JNDI名称,例如Glassfish?

Does Weblogic use portable JNDI names like Glassfish?

我可以找到(像Glassfish一样)使用JNDI名称的EJB部署的痕迹吗?

Can I find (like for Glassfish) a trace of EJB deployment with JNDI names used?

例如:


  • 仅具有@Remote的接口(服务)

  • 仅具有@Stateless实现的接口的bean(ServiceImpl)

  • 所有打包在 .ear 文件(service-application-1.0)中的文件

  • an interface (Service) with only @Remote
  • a bean (ServiceImpl) with only @Stateless implementing the interface
  • everything packaged in an .ear file (service-application-1.0)

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

When deploying on Weblogic the only JNDI reference I see is:

service-application-1.0service-application-1.0_jarServiceImpl_Home

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

but I can't use that name with a context lookup. If I do

Service myService = (Service) context.lookup("service-application-1.0service-application-1.0_jarServiceImpl_Home");

它给了我

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)

PS。有了Glassfish,它给了我

PS. With Glassfish it gives me

Portable jndi names for .... : java:global/service-application-1.0/service-application-ejb-1.0/ServiceImpl

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

正在工作。

推荐答案

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

Unfortunately, EJB 3.0 does not specify a standard JNDI naming and leave it up to the server vendor. You are right by quoting WL documentation about mappedName: "If you specify this attribute, the stateless session bean may not be portable". The drawback of mappedName attribute is that the global JNDI name will be default to mappedName#FullyQualifiedRemoteInterface. Since mappedName is an annotation within the source code, it makes your code non-portable. The preferred way is to keep vendor-specific behavior in vendor specific deployment descriptors, such as weblogic-ejb-jar.xml. This way, you also have the choice of specifying your own custom JNDI name without the predetermined format as mappedName#FullyQualifiedRemoteInterface.

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

EJB 3.1 made some efforts to standardize JNDI names at global,application, and module levels. Please see http://docs.oracle.com/cd/E19798-01/821-1841/girgn/index.html

这篇关于Weblogic 10.3.5及更高版本EJB 3 JNDI名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆