Making a remote ejb call

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.
bhojwanc1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bhojwanc1Author Commented:
remote ejb call
0
petmagdyCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
petmagdyCommented:
and one more thing u need the remote and home of the called EJB in ur EAR
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.