12 Replies Latest reply on Mar 30, 2010 7:17 AM by Carlo de Wolf

    EJB2 SB calls EJB3 SB and gets wrong Remote Interface

    Volker Raum Newbie

      Hi,
      i encountered a strange behaviour in JBoss 5.1.0 if a EJB2 SessionBean tries to lookup a EJB3 Session Bean.

      The situation is as follows:

      1. The EJB3 is coded like that:
      ...
      @Stateless(name="EJB3")
      @RemoteHome(EJB3Home.class)
      public class EJB3Bean implements EJB3
      {
      ...

      2. EJB3Home looks like this:
      public interface EJB3Home extends EJBHome
      {
      public EJB3Remote create() throws CreateException, RemoteException;
      }

      3. EJB3 is the EJB3 Business Remote Interface and looks like this:
      @Remote
      public interface EJB3
      {
      public void doThings() ;

      4. EJB3Remote is a Remote Interface according to the EJB2 Spec:

      public interface EJB3Remote extends EJBObject
      {
      public void doThings() throws RemoteException ;
      ...

      5. For the EJB2 there is a deployment descriptor defined. The section for the EJB2 Session Bean contains the following ejb-ref:
      ...
      <ejb-ref>
      <ejb-ref-name>EJB2Remote</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      EJB3Home
      EJB3Remote
      <ejb-link>EJB3</ejb-link>
      </ejb-ref>
      ...

      6. The EJB2 does a Lookup like
      Object obj = jndi.lookup("EJB2Remote") ;

      What i would expect is an object implementing EJB3Home.
      I can call create() with it and get a EJB3Remote Object.

      But what i get instead is an object of type EJB3, the Business Interface.
      This confuses me and is different to Bea Weblogic 10.3.1.
      Bea correctly delivers the Home.

      Since we have to develop for Bea and JBoss i need to find a way to get the Remote Interfaces the same way.

      Anything i did wrong to get the EJB3Home?

      I already checked the following links for help:
      http://java.sun.com/mailers/techtips/enterprise/2007/TechTips_Feb07.html
      and
      http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html/EJB2.1_and_EJB3_references.html

      Both articles presented ways to interact that did not work on both App Servers.

      Greetings
      Volker