• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Accessing ejb classes from a war file

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whats happenening when you are doing a JNDI lookup and calling the EJB methods? Does it throw some exception?
 
shawn kennedy
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!