-
1. Re: jndi lookup fails in user-thread
morphy Oct 4, 2011 9:05 AM (in response to inet_gbo)1 of 1 people found this helpfulQuite strange that it works in glassfish, as far as i know, the jndi name is "modular" (same module...but war is a different module or do you deploy the ejb in the war?)... you should use "application" if they (jar and war) are packaged in the same ear or "global" if not...
startup logs shows the jndi names available for that ejb...
anyway, i would ilke to suggest you the timer service instead of running a thread in the context listener, in the listener lookup for the timed object and use the jee service... let the application server to be the owner of threading
bye
-
2. Re: jndi lookup fails in user-thread
inet_gbo Oct 4, 2011 9:14 AM (in response to morphy)Hi Riccardo,
all 3 classes are deployed in a war. So the JNDI-Name should be o.k.
In the application I am working on we need to have the control over some threads - it is not possible to use the timer service ...
Günther
-
3. Re: jndi lookup fails in user-thread
morphy Oct 4, 2011 9:21 AM (in response to inet_gbo)can you try the lookup in a managed bean? just for test purposes...
-
4. Re: jndi lookup fails in user-thread
inet_gbo Oct 4, 2011 9:43 AM (in response to morphy)Hi,
I updated the code of StartupListener. It now calls StartupListener.doLookupTest() where I perform the same JNDI-lookup as in TestThread.callTestEjb().
It works in StartupListener, but it doesn't work in TestThread.
Here are parts of the server.log:
the jndi bindings:
15:28:21,342 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named TestEjb in deployment unit deployment "webtest1.war" are as follows:
java:global/webtest1/TestEjb!gbo.ejb.TestEjb
java:app/webtest1/TestEjb!gbo.ejb.TestEjb
java:module/TestEjb!gbo.ejb.TestEjb
java:global/webtest1/TestEjb
java:app/webtest1/TestEjb
java:module/TestEjb
...
the lookup performed in StartupListener which works:
15:28:25,420 INFO [gbo.servlet.StartupListener] (MSC service thread 1-1) before lookup of TestEjb
15:28:25,435 INFO [gbo.servlet.StartupListener] (MSC service thread 1-1) after lookup of TestEjb
15:28:25,435 INFO [gbo.servlet.TestThread] (Thread-20) TestThread started
15:28:25,435 INFO [gbo.servlet.TestThread] (Thread-20) before lookup of testEjb
the lookup in the new Thread which doesn't work:
15:28:25,435 WARNUNG [gbo.servlet.TestThread] (Thread-20) naming-Exception: javax.naming.NameNotFoundException: java:module/TestEjb
at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:55)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:209)
at javax.naming.InitialContext.lookup(InitialContext.java:392) [:1.6.0_27]
at gbo.servlet.TestThread.callTestEjb(TestThread.java:37) [classes:]
at gbo.servlet.TestThread.run(TestThread.java:24) [classes:]
Thanks for your help
Günther
-
5. Re: jndi lookup fails in user-thread
morphy Oct 4, 2011 11:05 AM (in response to inet_gbo)good you can pass the InitialContext instance to a concrete implementation of Runnable interface... build the Thread from that Runnable and... ?
-
6. Re: jndi lookup fails in user-thread
inet_gbo Oct 4, 2011 11:40 AM (in response to morphy)Hi,
passing the InitialContext instance into the thread does not work.
It ends up in a NameNotFoundException
Günther
-
7. Re: jndi lookup fails in user-thread
morphy Oct 4, 2011 11:41 AM (in response to inet_gbo)i surrender, i'm sorry
-
8. Re: jndi lookup fails in user-thread
jaikiran Oct 6, 2011 7:56 AM (in response to inet_gbo)1 of 1 people found this helpfulCreating threads from within the servlet or any EE component isn't recommended by the spec. The JNDI lookup of "app", "module" and "comp" won't work in those threads. See this for details http://lists.jboss.org/pipermail/jboss-as7-dev/2011-June/002292.html
-
9. Re: jndi lookup fails in user-thread
inet_gbo Oct 7, 2011 7:29 AM (in response to jaikiran)Hi,
It works with the global namespace: "java:global/webtest1/TestEjb"
I appologize not trying that earlier . Sorry!
I'm new to JEE and do not really understand the different namespaces.
Do you know a good documentation about that topic?
Do you think I can get problems using that global namespace in my user-thread?
In the user-thread I'd like to delegate all work to an ejb. That ejb depends on other ejbs (using hibernate or jdbc for db-access).
Many thanks for your time!
Günther