Discussion:
EJB local interface JNDI problems
(too old to reply)
Stuart Bramley
2004-10-28 07:28:27 UTC
Permalink
I am currently evaluating Weblogic 8.1 and am having problems with a simple session EJB that has both a local and remote interface. The remote interface seems to be fine, but the local interface does not seem to appear in JNDI correctly.

When I view the JNDI tree in the console, the remote EJB interface has a bound object that appears as follows:

Bound Object

Bind Name: BEARemote
Object Class: ejb.example.bean.BEA_umanf4_HomeImpl_812_WLStub
Object Hash Code: 8497786
Object To String: ClusterableRemoteRef(7028190383415656344S:10.43.137.128:[7001,7001,7002,7002,7001,7002,-1,0,0]:workshop:cgServer [7028190383415656344S:10.43.137.128:[7001,7001,7002,7002,7001,7002,-1,0,0]:workshop:cgServer/294])/294


However the local interface only has the following :

Bound Object

Bind Name: BEALocal

When I attempt to perform a JNDI lookup on "BEALocal" in a servlet, I get the following exception :

javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException: While trying to look up /app/ejb/beaejb.jar#BEA/local-home in /app/webapp/TestBEA/16449174.; remaining name '/app/ejb/beaejb/jar#BEA/local-home'

Because of the lack of detail on the bound object in JNDI I believe that this must be something to do with the definition of the interface - but I think that everything is correct.

The deployment descriptors are as follows :

ejb-jar.xml

<ejb-jar>
<enterprise-beans>
<session>
<display-name>BEA EJB</display-name>
<ejb-name>BEA</ejb-name>
<home>ejb.example.interfaces.BEARemoteHome</home>
<remote>ejb.example.interfaces.BEARemote</remote>
<local-home>ejb.example.interfaces.BEALocalHome</local-home>
<local>ejb.example.interfaces.BEALocal</local>
<ejb-class>ejb.example.bean.BEABean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

weblogic-ejb-jar.xml

<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>BEA</ejb-name>
<enable-call-by-reference>True</enable-call-by-reference>
<jndi-name>BEARemote</jndi-name>
<local-jndi-name>BEALocal</local-jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>

application.xml

<application>
<display-name>BEA Example</display-name>
<description>BEA Example</description>
<module>
<ejb>beaejb.jar</ejb>
</module>
</application>

Does the evaluation version have some limitation that means it does not support local interfaces? Is it a bug in Weblogic, or is there something incorrect in the definition of the local home interface above? As mentioned above, the "BEALocal" object name definition appears in JNDI, but with no generated stub class.
Stuart Bramley
2004-10-28 09:19:46 UTC
Permalink
No, I'm not using portable remote lookup.

The relevant code for the lookup is as follows:

/**
* Look up the bean's home interface using JNDI.
*/
protected BEALocalHome lookupHome() throws NamingException
{
Context ctx = getInitialContext();

try {
Object obj = ctx.lookup("BEALocal");
BEALocalHome home = (BEALocalHome) obj;
return home;

} catch (NamingException ne) {
System.out.println("The client was unable to lookup the EJBHome. Please make sure " +
"that you have deployed the ejb with the JNDI name " +
"BEALocal on the WebLogic server at "+ url);
throw ne;
}
}


/**
* Get an initial context into the JNDI tree.
*/
private Context getInitialContext() throws NamingException {

try {
// Get an InitialContext
Hashtable h = new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, url);
return new InitialContext(h);
} catch (NamingException ne) {
System.out.println("We were unable to get a connection to the WebLogic server at "+url);
System.out.println("Please make sure that the server is running.");
throw ne;
}
}
ebi ugo
2004-10-28 09:30:26 UTC
Permalink
did your getting the remote home come out successfully?
Stuart Bramley
2004-10-28 09:39:38 UTC
Permalink
Yes, if I try and get the remote interface there is no problem.

I'm sure that the problem is connected to the fact that there is no stub class for the local interface visible in the JNDI tree...
Amit Mujawar
2004-12-03 05:52:22 UTC
Permalink
Does the deployment give any error for the ejb? esp for local one.

If yes, pls try deploying the same bean separately as a different name but only with local interface.

Regards
Amit
Murteza.Salemi@capgemini.no
2005-02-10 16:02:50 UTC
Permalink
Hi StuBramley

I have the same problem when deploying local interfaces to the weblogic 8.1. The localhome interface does not appear on the JNDI tree and the local interface has just the bind name.

If you managed to solve the problem could you please tell me how you did it. my email address is ***@yahoo.com

thanks
Allen Pang
2005-02-14 02:00:58 UTC
Permalink
Hi,

I also have such problem. I got little more information for this problem. More precise, this problem does not occur if I deploy the application on the Domain's Administration Server Instance. This problem only occur if I deploy the application on a managed server in the Domain.

Thanks.
Stuart Bramley
2005-02-14 14:05:40 UTC
Permalink
For me the problem was simply that I had deployed the EJB and the servlet in different applications... I didn't realise that the local interface was scoped to the application rather than the container...
ebi ugo
2004-10-28 09:10:12 UTC
Permalink
it's very likely you are using portableremote lookup. confirm you aren't using portable remote lookup for a local jndi reference.
pradeep tiwari
2004-12-03 16:49:59 UTC
Permalink
Hi
I have made an application according to your requirement one ejb module ,one web module in which jsp is calling the session bean through local interface on weblogic 8.1 sp3(evaluation version) but it is working correctly.If you want i can send the application to you.
rwoollen
2004-12-04 01:45:01 UTC
Permalink
First off, locals can only be used within an application. So your servlet and the EJB should be packaged together in an EAR.

For locals, I would not recommend that you have a local-jndi-name in your weblogic-ejb-jar.xml. This puts the EJB in the global JNDI tree which isn't really correct for locals since they're application-scoped.

Instead, I would recommend that you reference the local via ejb-links.

In your servlet's web.xml, you should have something like this:

<ejb-local-ref>
<ejb-ref-name>ejb/MyEJB</ejb-ref-name>
<ejb-ref-type>entity</ejb-ref-type>
<local-home>MyHome</local-home>
<local>MyLocal</local>
<ejb-link>../myejb.jar/MyEJB</ejb-link>
</ejb-local-ref>

Then in your servlet you can look up the local EJB in the application-scoped JNDI tree:

Context ctx = new InitialContext();

MyHome h = (MyHome) ctx.lookup("java:comp/env/ejb/MyEJB");

-- Rob
Loading...