*
The moose likes EJB and other Java EE Technologies and the fly likes EJB Local Bean Call from Web Container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB Local Bean Call from Web Container" Watch "EJB Local Bean Call from Web Container" New topic
Author

EJB Local Bean Call from Web Container

gokul maha
Greenhorn

Joined: Jun 27, 2006
Posts: 25
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
Sumit Malik
Ranch Hand

Joined: Jan 05, 2007
Posts: 84
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


If at first you don't succeed, don't try skydiving
gokul maha
Greenhorn

Joined: Jun 27, 2006
Posts: 25
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

Joined: Jan 05, 2007
Posts: 84
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
 
 
subject: EJB Local Bean Call from Web Container
 
Similar Threads
Remote call or local call?
Why my ejb module is missing?
EJB3 Dependency Injection confusion
Problem in Clubbing Web module and EJB module
local interface ?