-
Looking up local ejb in custom thread.. (2 messages)
- Posted by: Mehmet Serkan Gunacti
- Posted on: December 17 2008 09:05 EST
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.Threaded Messages (2)
- Re: Looking up local ejb in custom thread.. by Nicke G on December 19 2008 09:20 EST
- Re: Looking up local ejb in custom thread.. by shreenee josh on December 22 2008 10:16 EST
-
Re: Looking up local ejb in custom thread..[ Go to top ]
- Posted by: Nicke G
- Posted on: December 19 2008 09:20 EST
- in response to Mehmet Serkan Gunacti
When you create your own thread, the security context and other contexts (thread local resources) are not automatically copied to the new thread. Therefore, the approach you are trying is simply not possible using WAS without writing a lot of work around code to help you out. Simply try to avoid creating custom threads if it means that you need access to the server's resources, or treat them strictly as "remote clients". /N -
Re: Looking up local ejb in custom thread..[ Go to top ]
- Posted by: shreenee josh
- Posted on: December 22 2008 10:16 EST
- in response to Nicke G
Simply try to avoid creating custom threads if it means that you need access to the server's resources, or treat them strictly as "remote clients".
Very aptly put in words by Nick. But if Nick's method is not feasible, do the lookup part in servlet thread and pass the reference to the custom thread. I believe this may work (I have never tried this myself though)