aspose file tools*
The moose likes Websphere and the fly likes Looking up local ejb in custom thread.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Looking up local ejb in custom thread.." Watch "Looking up local ejb in custom thread.." New topic
Author

Looking up local ejb in custom thread..

Mehmet Gunacti
Ranch Hand

Joined: Oct 26, 2004
Posts: 34
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

Joined: Oct 26, 2004
Posts: 34
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.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Looking up local ejb in custom thread..