9 Replies Latest reply on Aug 2, 2007 2:51 PM by jainsau

    @EJB injection always injects remote object, why not local

    jainsau

      I have a stateless EJB, and have another EJB injected into this EJB. The injection is straight forward:

      @EJB
      BeanInteface interface;

      The BeanInterface is available in both remote and local forms in the jmx-console-> JNDI view-> list. I am running JBoss 4.2.0 GA, on a single system, so the injection could also return a local proxy. But I always get a remote proxy. I even tried to attribute the injection like this:

      @EJB (name="earName/beanName/local")
      BeanInteface interface;

      but still I only get the remote proxy in the interface variable. Why is this happening? Why can't I fetch the local proxy via injection?

      Another slightly related question. Is there a way to find out at runtime (by enquiring the conatiner ?) whether an EJB is available locally or remotely so that I can try to access the correct proxy?