]
Andrew Lee Rubinger resolved EJBTHREE-1154.
-------------------------------------------
Resolution: Done
Has been previously fixed by related issues, Unit Tests pass with no code modification
2.1 Home create() implementation returns wrong type
---------------------------------------------------
Key: EJBTHREE-1154
URL:
http://jira.jboss.com/jira/browse/EJBTHREE-1154
Project: EJB 3.0
Issue Type: Bug
Reporter: Andrew Lee Rubinger
Assigned To: Andrew Lee Rubinger
Priority: Critical
Fix For: AS 5.0.0.Beta3
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
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: