Making a remote ejb call

Posted on 2004-11-06
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.
Question by:bhojwanc1

    Author Comment

    remote ejb call
    LVL 13

    Accepted Solution

    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:
    in ur /WEB-INF/web.xml define resource reference like this:
          <ejb-ref id="EjbRef_1">

    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"/>

    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
    LVL 13

    Expert Comment

    and one more thing u need the remote and home of the called EJB in ur EAR

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now