GeeCON Prague 2014*
The moose likes EJB and other Java EE Technologies and the fly likes EJB 3.0 / Glassfish2u2 / JNDI Lookup for Local Interface  :shock: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB 3.0 / Glassfish2u2 / JNDI Lookup for Local Interface  :shock: " Watch "EJB 3.0 / Glassfish2u2 / JNDI Lookup for Local Interface  :shock: " New topic
Author

EJB 3.0 / Glassfish2u2 / JNDI Lookup for Local Interface :shock:

Mohammad Rezwan
Greenhorn

Joined: Jan 13, 2009
Posts: 6
I got really puzzled about JNDI lookup for local interface in Glassfish2u2.

Whenever I call remote interface like

InitialContext ctx = new InitialContext(); TestingRemote testingBeanJndi = (TestingRemote) ctx.lookup(TestingRemote.class.getName());

It works fine.........

But

InitialContext ctx = new InitialContext(); String strLookUp = ""java:comp/env/ejb/TestingBean"; TestingLocal testingBeanJndi = (TestingLocal) ctx.lookup(strLookUp);

It doesn't work...
I tried
strLookUp = ""java:comp/env/TestingBean";

I also tried like
@Stateless(name="ejb/TestingBeanLocal") // previously I didn't overwrite 'name'
public class TestingBean implements TestingRemote, TestingLocal { }

AND

strLookUp = ""java:comp/env/ejb/TestingBeanLocal";

Not working as well.


Could anyone please help me?

And could I get list for all JNDI env by using any command?

PS -- I am packing in the Beans in ear file.

SCJP 5.0 (88%), preparing for SCBCD
Dhiren Lodhia
Greenhorn

Joined: Mar 05, 2008
Posts: 14
Mohammad Rezwan wrote:I got really puzzled about JNDI lookup for local interface in Glassfish2u2.

Whenever I call remote interface like

InitialContext ctx = new InitialContext(); TestingRemote testingBeanJndi = (TestingRemote) ctx.lookup(TestingRemote.class.getName());

It works fine.........

But

InitialContext ctx = new InitialContext(); String strLookUp = ""java:comp/env/ejb/TestingBean"; TestingLocal testingBeanJndi = (TestingLocal) ctx.lookup(strLookUp);

It doesn't work...
I tried
strLookUp = ""java:comp/env/TestingBean";

I also tried like
@Stateless(name="ejb/TestingBeanLocal") // previously I didn't overwrite 'name'
public class TestingBean implements TestingRemote, TestingLocal { }

AND

strLookUp = ""java:comp/env/ejb/TestingBeanLocal";

Not working as well.


Could anyone please help me?

And could I get list for all JNDI env by using any command?

PS -- I am packing in the Beans in ear file.


Where are you putting this look up code??
in which component (Servlete or app client ......)

Dhiren

Dhiren Lodhia
SCJP 5.0 (93%)
Mohammad Rezwan
Greenhorn

Joined: Jan 13, 2009
Posts: 6
I need JNDI Lookup from POJO
Mohammad Rezwan
Greenhorn

Joined: Jan 13, 2009
Posts: 6
I found the answer from following two URLs

1.http://www.nabble.com/lookup-ejbs-td19961900.html
2.https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#POJOLocalEJB
 
GeeCON Prague 2014
 
subject: EJB 3.0 / Glassfish2u2 / JNDI Lookup for Local Interface :shock: