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.
posted 10 years ago
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.
Enjoy the full beauty of the english language. Embedded in this tiny ad: