Publishing EJB's local interface in weblogic
Asked Answered
A

3

2

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.

Abebi answered 22/6, 2010 at 15:4 Comment(1)
What version of WebLogic are you using? What you want is easy in WebLogic 12c.Grubby
U
7

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.

Ucayali answered 16/4, 2013 at 8:13 Comment(2)
I know this is an old thread . But this statement --- "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." saved my day.. @Ucayali Thanks for being explicitly clear !Beadledom
my god....god bless u... Only RemoteInterface....Oracle-WebLogic staff...this is for u: what the heck!?!?Copepod
K
1

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).

Kettledrum answered 12/11, 2013 at 13:59 Comment(0)
O
0

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

Outthink answered 22/6, 2010 at 15:7 Comment(1)
Can you elaborate on that? How the JNDI name should look like? I forgot to mention that I am quite new to EJB3 so maybe I am missing something obvious ...Abebi

© 2022 - 2024 — McMap. All rights reserved.