• 1 reply
  • Latest Post - ‏2008-12-17T16:36:35Z by SystemAdmin
11979 Posts

Pinned topic Looking up local ejb in custom thread..

‏2008-12-17T16:30:51Z |
We use Websphere 6.0.

I have a web project and an ejb project. when looking up a local ejb through a reference in web.xml 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 ? Are there any known side effects ?

if not what would be a workaround to the NameNotFoundException ?

(i tried to lookup the local ejb with "local:" at the beginning of the jndi name and succeeded, but that's something Websphere uses internal and not thought of public use)

Randy Schnier wrote in a post here :
"The local home
is bound into an internal namespace within the server and should be
accessed via an ejb-local-ref defined in the calling component (which
will be bound by the container into the calling component's
java:comp/env component-specific namespace)."

but how can I access the (Web) component-specific namespace inside a subclass of java.lang.Thread ?

Thanks in advance.
Updated on 2008-12-17T16:36:35Z at 2008-12-17T16:36:35Z by SystemAdmin
  • SystemAdmin
    11979 Posts

    Re: Looking up local ejb in custom thread..

    Sorry, I'm in the wrong forum. I reposted it to the application server forum.
    there's no delete post link here.