• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need JNDI Lookup from POJO
 
Mohammad Rezwan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic