How to call Remote EJB's using ejb-ref?


EJB programming & troubleshooting: How to call Remote EJB's using ejb-ref?

  1. How to call Remote EJB's using ejb-ref? (3 messages)

     I need to call a ejb deployed in remote server.I was able to call it using the direct JNDI name,like this in my client code-

    Object obj1=ic.lookup("ejb/statelessSBean");

    To call the same ejb using the ejb-ref,
    Is this syntax is correct?

    Object obj1=ic.lookup("java:comp/env/ejb/remoteSessionBean");

    where ejb/remoteSessionBean is been mapped to ejb/statelessSBean in the descriptors.

  2. Looks correct to me. Why are you asking? Doesn't it work?
  3. YES, that didn't work for me!
    and also i like to know,where i can find more information about the meaning of this syntaxt-

    Is this something different for remote lookup?

    thanks again.
  4. The "java:comp/env" context is used for resources mapped for an EJB using the deployment descriptors. It's a kind of a "private namespace".

    In other words, you can't do
    new InitialContext(props).lookup("java:comp/env/foobar");
    from anywhere else but within the component for which the resource was defined. You can't lookup objects from the private context from a remote client (remote as in outside-of-the-EJB).