Publishing EJB's local interface in weblogic

旧城冷巷雨未停 提交于 2020-01-13 06:11:29

问题


is there a way to lookup an EJB in weblogic if it implements only local interface?

If I use this

@Remote public interface TestSessionRemote { 
    public void businessMethod();
}

@Stateless(mappedName = "A")
public class TestSessionBean implements TestSessionRemote 
{
    public void businessMethod() 
    {

    }
}

the EJB can be looked up using this name:

"A#" + TestSessionRemote.class.getName()

If I change the annotation for TestSessionRemote from @Remote to @Local the EJB disappears from JNDI. Is there a way around this?

EDIT: I was working with Weblogic 10.3.x (aka 11g) at that time.


回答1:


No, it is not possible. I have been working through the same issue, in the context of deploying an EJB 3.0 application on WebLogic 10.3.x.

The application runs on Oracle Application Server 10.1.3 and GlassFish 3.x.

  • Oracle AS (OC4J) has a proprietary mechanism for looking up the local interface of an EJB using JNDI.
  • GlassFish 3.x implements EJB 3.1 with its portable JNDI name syntax.

Our application uses a lookup mechanism for the current application server, which is determined at runtime.

In WebLogic Server 10.3, the local interface of an EJB:

  • can be injected into managed classes in the servlet container (servlets, filters etc.) and other EJBs using @EJB annotations
  • is only available for lookup from JNDI when it has been declared in a ejb-local-ref element in web.xml or ejb-jar.xml

It is not practical for us to declare all EJBs that are looked up. We have 192 stateless EJBs, mostly injected but many looked up from JNDI because we need them available to unmanaged classes.

My source for this information, apart from trial and error, is WebLogic 10.3 EJB3 Local Lookup Sample. Almost everything else I found, including the Oracle documentation, describes the JNDI lookup syntax with mappedName#fullInterface but does not make it clear that only the remote interface name is in the JNDI tree.

Update: We went with declarations in web.xml and ejb-jar.xml (yes, there are EJBs that use utility classes that look up other EJBs in JNDI). Started with a script to generate them from sources then manually edited them until they were correct. Not nice but necessary.




回答2:


A few more detail, check verification in Ejb3SessionBinder#bindToJNDI() skips the code binding with jndi and Home interface, this means: no local beans are callable from jndi tree because these wasn't registered. As has been said, is only available for lookup from JNDI when it has been declared in a ejb-local-ref element in web.xml or ejb-jar.xml.

(This information refer to wls 10.3.5).




回答3:


It should still be in the java:comp/env namespace.



来源:https://stackoverflow.com/questions/3094427/publishing-ejbs-local-interface-in-weblogic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!