• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Lost Home reference

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You got style baby! More than this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic