• Post Reply Bookmark Topic Watch Topic
  • New Topic

Lost Home reference

 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Not sure If I need to post my question in EJB section or Servlet section as I'm actually trying to lookup a Stateless Session bean

Please find my servlet code


and my code for ServiceLocator


Output on console
16:35:38,203 INFO [STDOUT] New Code
16:35:38,265 INFO [STDOUT] Object is :ejb/GreetingHome
16:35:38,265 INFO [STDOUT] Greeting Home is :ejb/GreetingHome
16:35:38,265 INFO [STDOUT] GH is:null
16:35:38,265 ERROR [Engine] StandardWrapperValve[Controller]: Servlet.service() for servlet Controller threw exception
java.io.IOException: Could not create Home

Now my question is why did GH has become null suddently when it is displayed just a step above in the doGet() method.

Please help me in identifying the problem.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi,
"GreetingHome gh=(GreetingHome) ..." - This creates a variable local to the try/catch block which masks the servlet level one.

"gh=(GreetingHome) ..." - This would assign the home interface to the instance variable in your servlet.

In general, I would put questions like this in the EJB forum since they have to with EJB lookup. In this case, it was a Java language thing and either place is fine.
 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,

Thanks for reminding me about the scope of the variables. I have completely overlooked that I have already my GreetingHome reference declared . Thanks for catching me here and letting me know my mistake.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!