• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCBCD: InitialContext Lookups On Local Clients

 
Jason Mowat
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,

I am having some problems on RI doing a lookup from one bean to another as a local lookup.

I have 2 beans deployed, one with remote interfaces (I called it "Answer" in JNDI) and one with pure local interfaces (I called it "Dice" in JNDI). In my bean that is deployed with the remote interfaces, "Answer", I am trying to fetch the LocalHome of the local bean, "Dice". The code in AnswerBean is as follows:



My expectation is that I should see "Local call: You rolled a 3" echoed in the console screen where I started the RI server.

Even though I have deployed "Dice" successfully, this chunk of code throws: "javax.naming.NameNotFoundException: Dice not found". I am not sure if my InitialContext requires anything special when it is being called from within the container, or if my lookup reference of "Dice" needs something special added to the beginning of it.

Any help is appreciated!

Cheers,
Jason
 
Jason Mowat
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As an update:

I am trying to deploy both AnswerBean and DiceBean as 2 separate EAR files.

It appears that I need to specify EJBs referenced in code for AnswerBean in deploytool, which makes sense. I specify the coded name of "Dice", type "Session", Interfaces "Local", HomeInterface "DiceLocalHome" and Local/Remote Interface "DiceLocal". I also specify an enterprise bean of "ejb-jar-ic.jar#AnswerBean" because it is the only option in the drop down.

It seems that I need to include DiceBean somehow in AnswerBean prior to deployment, but I'm not sure how.

Hope that makes sense and adds value at the same time :-)

Cheers,
Jason
 
Jason Mowat
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 175 of HFEJB, it states:


...the container isn't required to allow a bean in one EAR file to be a local client to a bean in a different EAR...


I'm speculating that that is part of my problem, although I'm not sure due to my lack of experience.

Cheers,
Jason
 
Jason Mowat
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it appears that I had to do a few things:

1. Bundle the bean JARs into a single EAR
2. Place a reference on Answer to Dice
3. Set the initial context lookup to "java:comp/env/Dice" instead of just "Dice" for the bean-to-bean local communication.

It works, although I think I'll have to experiment with it a bit to wrap my head around the details.

Cheers,
Jason
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic