2 Replies Latest reply on Sep 30, 2001 12:28 PM by tobias

    Using a subclass for an Entity Bean implementation

    juliaac

      Hey, I have a class which implements Entity Bean and has some common functionality.

      For example:

      public class CommonEntityBean implements EntityBean {
      public Long id;
      public void setId(Long val) { id = val; }
      public Long getId() { return id; }
      }

      Then I have a few subclasses which extend it:

      public class AlphaEntityBean extends CommonEntityBean {
      // some stuff specific to AlphaEntityBean
      }

      Then I have a remote interface to go with it:

      public interface Alpha extends EJBObject {
      public void setId(Long val) throws RemoteException;
      public Long getId() throws RemoteException;
      }

      When I deploy it says -
      Section: 9.2.7
      Warning: For each method defined in the remote interface, there must be a matching method in the entity bean's class that has the same name and argument types.

      The matching method is there, it's public, it's just in the superclass, and when I paste it into the subclass code it works fine.

      So why can't the deployer see public methods in the superclass?

      Is this a bug in JBoss or is does the EJB spec say that you can't subclass an EJB implementation class?

      Thank you.

        • 1. Re: Using a subclass for an Entity Bean implementation

          Hi Juliaac

          Is your super class implementing

          ejbCreate()
          ejbPostCreate()
          ejbRemove()
          ejbActivate()
          ejbPassivate()
          public void ejbLoad()
          public void ejbStore()

          ?

          I think they have to be implemented due to the Sun J2EE specification.

          Jesper

          • 2. Re: Using a subclass for an Entity Bean implementation
            tobias

            You need to have the same subclassing schema on the remote interfaces.
            Meaning:
            public interface CommonEntityBean extends EJBObject
            AND
            public interface Alpha extends CommonEntityBean

            The home interfaces DO NOT use subclassing.
            It works this way, I have done and used it. Our system is in production with it.

            Tobias