Publishing EJB's local interface in weblogic
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 a开发者_C百科round this?
EDIT: I was working with Weblogic 10.3.x (aka 11g) at that time.
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 inweb.xml
orejb-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.
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).
It should still be in the java:comp/env namespace.
精彩评论