Uploaded image for project: 'EJB 3.0'
  1. EJB 3.0
  2. EJBTHREE-1154

2.1 Home create() implementation returns wrong type

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • AS 5.0.0.Beta3
    • None
    • None
    • None

    Description

      EJB3 Mirror issue of JBAS-5036.

      Local home (and presumably remote, too) implementation for EJB 3 sessions creates an object that is an instance of the local business interface of the EJB 3 session, and returns that. This is contrary to EJB 3 specification, which says that local home create methods must return an instance of the local interface of the EJB 3 session (as in: not local business interface).

      The type of the local interface is apparently deduced from the return type of the create method in the local home interface (there is no annotation for it).

      For beans that follow the specification, this causes a class cast exception when create() is called: the local home interface is specified to return an instance of local interface, but the implementation JBoss supplies creates a instance of local business interface (I presume so, because changing local home to return that works), and then we end up with class cast exception.

      There is no workaround other than going against specification in code: define local home interface to return instance of local business interface.

      This simple session, which as far as I can see is exactly according to EJB 3 spec, illustrates the problem, and does not work on JBoss 4.2.1.GA:


      @javax.ejb.Stateless(name="Stateless")
      @javax.ejb.LocalHome(StatelessHome.class)
      @javax.ejb.Local(

      {StatelessLocal.class}

      )
      public class StatelessBean implements StatelessLocal { public void ejbCreate() {} }

      public interface StatelessLocal {}

      public interface StatelessHome extends javax.ejb.EJBLocalHome

      { public StatelessLocal21 create() throws javax.ejb.CreateException;}


      public interface StatelessLocal21 extends javax.ejb.EJBLocalObject, StatelessLocal {}

      When home is looked up, and create is called, the result is:

      java.lang.ClassCastException: $Proxy271 cannot be cast to StatelessLocal21

      Attachments

        Issue Links

          Activity

            People

              arubinge@redhat.com Andrew Rubinger (Inactive)
              arubinge@redhat.com Andrew Rubinger (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: