• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling EJB from Servlet

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
i'm sorry if i'm posting the query at the wrong place.
i just want to know how to call a Session EJB from my servlet.?
Is creating a home and remote interface using JNDI Naming operation works from my servlet's init()?
If so should I give a web.xml file along with weblogic-ejb-jar.xml and ejb-jar.xml................Or is there any other way.........plz do give me a quick reply.
Thanks in advance
 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amarender,

When you are learning anything for the first time, it is always suggested to follow some tutorial as they give step by step instructions to create, deploy and run for your target server. If you post such a newbie question, definitely sombody will give some answer, but it may be just an hint. However, that hint may not make any sense to you as you are still trying to learn. My honest opinion. However, let me try to answer my best.

There is a directory and file(s) structure you need to adhere to, if you want to deploy into any j2ee standard containers. Ejb files (home, remove, bean, pk if applicable, ejb-jar.xml, weblogic-ejb-jar.xml for weblogic) will be bundeled into the EJB Jar format. There is no point in duplicating the structure, as it is well explined in some sites. Just search for J2EE deployment. Once you bundeled your ejb files, you need to deploy into the container. When you deploy into the container, it will create a home object and bind to the JNDI name you specified in the vendor specific deployment descriptor.

In the Servlet, you get hooked up to the JNDI context, and look up that JNDI object using the name you have specified in the deployment descriptor. When you get your home object, as usual you can call the create method on it (with any required parameters), which will return you the Remote. Using remove you can invoke the business methods.

Hope this helps.
 
Amarender Reddy
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
santosh,
thanks a lot for your detailed reply
as suggested by you i have already browsed few sites for more info....
but that did not help me in implementing the said concepts.....
thats the reason i posted it here....any have i will do my best to gather more and understand the concepts....
your help is always welcome
thanks once again
amar
 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can call an EJB anywhere in a servlet. But of course, you must follow the rules of accessing it.

I'm sure weblogic has a good tutorial for this. Apparently it's your first time into ejb. Throwing in my 2-cents worth would not make it easier for you than recommending you to look for a tutorial you deem suitable.

A quick search through Google shows me a list of such site. One of those on top is this Weblogic EJB Tutorial..

Good luck! I don't know about you, but I've been needing a lot of them since I started.

Originally posted by amarender reddy:
hello,
i'm sorry if i'm posting the query at the wrong place.
i just want to know how to call a Session EJB from my servlet.?
Is creating a home and remote interface using JNDI Naming operation works from my servlet's init()?
If so should I give a web.xml file along with weblogic-ejb-jar.xml and ejb-jar.xml................Or is there any other way.........plz do give me a quick reply.
Thanks in advance

reply
    Bookmark Topic Watch Topic
  • New Topic