Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mohammad Rezwan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dhiren Lodhia
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mohammad Rezwan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need JNDI Lookup from POJO
 
Mohammad Rezwan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic