-
Bug
-
Resolution: Done
-
Critical
-
JBossAS-4.2.1.GA
-
None
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(
)
public class StatelessBean implements StatelessLocal { public void ejbCreate() {} }
–
public interface StatelessLocal {}
–
public interface StatelessHome extends javax.ejb.EJBLocalHome
–
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
- is blocked by
-
EJBTHREE-1071 Business Interface must not extend EJBObject or EJBLocalObject
- Closed
-
EJBTHREE-1127 Rework implementation requirements for @Remote, @RemoteHome
- Closed
- is duplicated by
-
EJBTHREE-1154 2.1 Home create() implementation returns wrong type
- Closed