• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EJB Local Bean Call from Web Container

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

My application has web module and ejb module bundled in a single ear. It will be deployed using this ear.

In my appl, can i make a local bean call from web module to ejb module?
ie. i have session bean as local interface in ejb module. Can i call this bean from any utility class in web module.

If not, then why?

If yes, please provide me a sample code for local bean initial context look up.



Thanks in Advance,
Gokul
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gokul,

I think you havent gone throught the basic tutorials of EJB. Well, yes you can call local/remote interface from webmodule. But how you want to do it totally depends on EJB version you are using..
If you are using EJB 2.x then you need to define the mapping of EJB modules in web.xml(then you need to work with the home/local-home interface and then you need to get remote/local interface....) and if you are using EJB 3.0 then by getting context of interface you can call service methods of it( and here you dont even have to call home interface !!!).

Do let me know if i can assist you in more effecient way....

Cheers !!!
Sumit Malik
 
gokul maha
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response.

I am using EJB2.0. The thing i want to know whether is it possible to call a Session bean implemented as local view in EJB module from WEB module. Since both have different containers, is it required that we need to make remote call ?
 
Sumit Malik
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Gokul I m not very much conversant with EJB2.x series and I have just come across with EJB 3.0 but let me see if i can assist you..

If you have packaged your application with all you ejb jar's and all web modules in a single ear file and you are using EJB2.x series then you need to get the context localhome interface. Through this interface you need to call create method which would return you local interface(actually stub/implementation of bean class).

Once you get local interface(or stub) you can call implemented business method(of interface) of bean through interface(local)...

I hope you must have got the clue that can you call local interface or not..... So with EJB 2.x you need to call home/localhome interface and not remote/local interface directly......


Cheers !!!
Sumit Malik
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic