• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

no Local EJB in thread ?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody !

I use timer.schedule() to launch small batches.
My problem is that I don't have access anymore to local EJB in those batch.
(With websphere 5.1)

In my web project, i can load local EJB without problem using initialContext.lookup("java:comp/env/ejb/myLocalEJB")
but in my batch, nope, error :
javax.naming.NameNotFoundException: Name "comp/env/ejb" not found in context "java:".

With initialContext.getNameInNamespace(), i found the same context "localhost/nodes/localhost/servers/server1" in a web servlet and in the batch. So I don't understand why cannot access this local EJB.

My understanding is that EJB are on the same serveur instance, so can be accessible in local , no ?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This really belongs in the EJB forum, so I'll move it there...

Where is this "batch" that you're referring to running?

In the application server?

In the same web application as the servlet you mentioned?

The reason that "java:comp/env/ejb/myLocalEJB" works in the servlet is because an <ejb-ref> has been defined in the web.xml of the web application that points to the real JNDI of the EJB. "java:comp/env" is a special JNDI subcontext defined for each web application or EJB deployment, and all the things inside of it are defined in the web app's or EJB's deployment descriptor.

If this "batch" that you refer to is in a different web application, you'll need to copy the <ejb-ref> from the original one to be able to access the EJB in this way. If the "batch" is not running in the application server, then you won't be able to access the EJB, since you said it's defined as local.
 
al Dupin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for choosing wrong forum.

the batch process is launch in the same web application.

I don't understand how the jndi context work, because the ejb-local-ref definition in the web.xml are ok, and thats's work good in the servlet.

I have put exactly the same code to retreive the local EJB in the servlet and batch.

maybe the use of timer.schedule is not a good way to launch a batch.
but in jdk 1.3, i don't now how to otherwise.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic