• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

SCBCD: InitialContext Lookups On Local Clients

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic