File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Accessing ejb classes from a war file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Accessing ejb classes from a war file" Watch "Accessing ejb classes from a war file" New topic
Author

Accessing ejb classes from a war file

shawn kennedy
Ranch Hand

Joined: Oct 31, 2002
Posts: 67
I have created a ear file that has many wars within it and a jar file containing the ejb classes.Now i want to access the ejb's present in tht jar from one of my wars.What all am i suppose to do to make this happen
Amit M Tank
Ranch Hand

Joined: Mar 28, 2004
Posts: 257
Whats happenening when you are doing a JNDI lookup and calling the EJB methods? Does it throw some exception?


Amit Tank
Linked In
shawn kennedy
Ranch Hand

Joined: Oct 31, 2002
Posts: 67
Well could you read my question again.I need to know whats to be done in order for me to call an ejb from a war file.I dont know what im supposed to do to make it happen
Amit M Tank
Ranch Hand

Joined: Mar 28, 2004
Posts: 257
How have you deployed the EJB? Whats the JNDI name of the EJB which you have exposed?

Do the JNDI lookup of the EJB through your client (Servelt/BusinessDelegate) in your wars and call the session bean method. Hope this helps.
shawn kennedy
Ranch Hand

Joined: Oct 31, 2002
Posts: 67
well have done tht bit what i mean to ask is if i have tht war in the ear how will the war look up the ejbs in the ear file.
Sunil Dixit
Ranch Hand

Joined: Sep 22, 2005
Posts: 46
Hi shawn,
It is very simple,Let me tell you step by step:

1. In you JAR file please make it sure that you have given EJB REF i.e. nick name to your EJB. Reason is it is not good to lookup any component by its actual JNDI name beacuse if you do that than your code is tightel coupled with JNDI name,which is wrong.
2. Mentioned those EJB REF in your web.xml file using <ejb-ref> or similar tag (please look on the web ).
3.Now in your servlet class simply do the lookup,rest of all will be taken care by the container itself.
but make it sure that while you do lookup you are using the same ref-name which you have given in web.xml file.

Hope that this will help you.

Cheers,
Sunil Dixit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing ejb classes from a war file