Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Looking up local ejb in custom thread..

 
Mehmet Gunacti
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
We use Websphere 6.0.

I have a web project and an ejb project. when looking up a local ejb stub in the web project everything works fine.

but if I try to lookup a local ejb stub in a thread that is created at the startup of a servlet I get a :

"Name comp/env/ejb not found in context "java:"." , NameNotFoundException.

When I create a Thread in the init() method of a servlet, within that thread's code I'm still in the web container/JVM, right ? or has it the same effect as if I'd code in a standalone java application ?

if the latter is true, would it be appropriate to create a stub in the init() method of the servlet and pass it to the thread after its creation ? I mean is it ok to cache a local ejb reference / stub ?

if not what would be a workaround to the NameNotFoundException ?

Thanks in advance.
 
Mehmet Gunacti
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I post this, just in case someone needs an answer to this.

We can't call InitialContext() within a thread created inside a servlet container and expect it to be initialized with the parameters passed to a InitialContext() instance created by the server process.

What I did, was simply creating an InitialContext instance and pass it to the thread.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic