This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Websphere and the fly likes local ejb reference from custom service Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Products » Websphere
Reply Bookmark "local ejb reference from custom service" Watch "local ejb reference from custom service" New topic
Author

local ejb reference from custom service

Stefan Edlund
Greenhorn

Joined: Aug 29, 2003
Posts: 5
Hi,
I have a custom service that gets initialized when the application server (WebSphere 5.0) start up. The problem is that I need to get a local reference to a session ejb in the custom service. There's no deployment descriptor where I can configure the reference, so how can I do this? I've tried adding the reference to the web.xml file (doesn't help, probably since it's not a servlet). Local ejb references defined in the EJB project only works inside other EJBs.
I'm stuck. Any ideas?
Thanks,
/ Stefan
Stefan Edlund
Greenhorn

Joined: Aug 29, 2003
Posts: 5
Not too happy with my current solution, but this is how I managed to get it working:
1. Create a servlet in the web project.
2. Configure the servlet to load at startup.
3. Define the local ejb reference in the web.xml file
4. Have the servlet create the singleton instance of the class where the local ejb reference is looked up. The singleton instance is cached.
5. When the custom service wakes up at a later time, it picks up the cached instance of the class and gets going.
Kind of ugly since I need to make sure that the servlet is initialized before the custom service wakes up (the custom service is a task scheduler). If anyone knows of a better solution, let me know.

/ Stefan
Sean Li
Ranch Hand

Joined: Feb 27, 2002
Posts: 154
how come if I don't define <ejb-ref-name>?
I want to look up the local bean directly from JNDI server. surpose the JNDI name of this local bean is:ejb/au/com/toyota/epc/ejb/ModelList/ModelListLocalHome, which I paste from ibm-ejb-jar-bnd.xml, what is the JNDI reference to use when in a session bean?
context.lookup(" WHAT TO WRITE HERE??? ");
help me, thanks!
Stefan Edlund
Greenhorn

Joined: Aug 29, 2003
Posts: 5
try:
ic.lookup("java:comp/env/ejb/au/com/toyota/epc/ejb/ModelList/ModelListLocalHome")
S SG
Greenhorn

Joined: Sep 03, 2003
Posts: 5
If you are referring the JNDI names from custom service, use the absolute names like
cells/<cell name>/nodes/<node name>/servers/<server name>/ejb/<ejabname>
S SG
Greenhorn

Joined: Sep 03, 2003
Posts: 5
cells/<cell name >/nodes/<node name>/servers/<server name>/ejb/<ejb name>
Stefan Edlund
Greenhorn

Joined: Aug 29, 2003
Posts: 5
Thanks,
great idea, but do you know in which deployment descriptor I define the local ejb reference so that it is available using an absolute path? I can easily find the remote ejb using something like:
cell/nodes/localhost/servers/server1/ejb/MyEjb
What about local ones?
Thanks,
/ Stefan
Stefan Edlund
Greenhorn

Joined: Aug 29, 2003
Posts: 5
Finally figured it out. Do a lookup on "local:ejb/<ejb-jndi-name>", and you'll get the local home for any ejb from any context (including a custom service).
/ Stefan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: local ejb reference from custom service
 
Similar Threads
EJB 3 Local Lookup not working with Weblogic 10.3
Local References in WebSphere 5.0
regarding JNDI
Please explain this to me -> JNDI issues
EJB 3 Local Lookup not working with Weblogic 10.3 and JDK 1.6_05