[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Making a remote ejb call

Posted on 2004-11-06
4
Medium Priority
?
320 Views
Last Modified: 2013-11-24
Can someone tell me how to make a remote ejb call?

I have two ear that are supposed to be deployed on WAS.  I want to make a remote ejb call from on to the other.
0
Comment
Question by:bhojwanc1
  • 2
3 Comments
 

Author Comment

by:bhojwanc1
ID: 12513522
remote ejb call
0
 
LVL 13

Accepted Solution

by:
petmagdy earned 2000 total points
ID: 12513655
if u r calling ur EJB from Web Module for example, and the EJB Bean is called Account example which have a JNDI name called for example myproject/mymodule/Account:
First:
in ur /WEB-INF/web.xml define resource reference like this:
      <ejb-ref id="EjbRef_1">
         <description>Account</description>
         <ejb-ref-name>ejb/Account</ejb-ref-name>
         <ejb-ref-type>Session</ejb-ref-type>
         <home>myfullpackage.AccountHome</home>
         <remote>myfullpackage.Account</remote>
      </ejb-ref>

Second: in ur /WEB-INF/ibm-web-bnd.xmi define resource reference--JNDI map like this:

  <ejbRefBindings xmi:id="EjbRefBinding_1" jndiName="myproject/mymodule/Account">
    <bindingEjbRef href="WEB-INF/web.xml#EjbRef_1"/>
  </ejbRefBindings>

Third:
in ur Code:

        Context initCtx = new InitialContext();
        Object o = initCtx.lookup("java:comp/env/ejb/Accunt");
        AccountHome home = (AccountHome) javax.rmi.PortableRemoteObject.narrow(o, AccountHome.class);
        Account account = home.create();
         // now call ur methods
        account.foo();
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12513667
and one more thing u need the remote and home of the called EJB in ur EAR
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
A solution for Fortify Path Manipulation.
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month18 days, 4 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question