This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB Local Bean Call from Web Container

 
gokul maha
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
 
Sumit Malik
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic