tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Gallimore <>
Subject Re: ClassCastException on JNDI lookup
Date Wed, 09 Jul 2008 08:57:45 GMT

I tried to replicate your class hierarchy with the simple-stateless 
example that comes with OpenEJB, and I wasn't able to reproduce your 
problem. I've popped my code up - 
perhaps you could have a look and let me know if my class hierarchy 
matches yours, or if there is anything I've missed in trying to 
reproduce the problem? (Or if you have some code you can share that I 
can try running that would be great too).

Could you also let me know which version of OpenEJB you're using, I've 
assumed you're using the released 3.0, and I've tested with both that 
and the latest from trunk.



chawax wrote:
> Hi,
> I try to use OpenEJB to run unit tests within a Maven project. Part of the
> code of this project is generated by AndroMDA MDA framework.
> For each EJB session bean, four classes are generated, to separate code
> generated once from code generated at each Maven install, to share code
> between local and remote EJB, etc ...
> For example for an EmployeeService local EJB I have the following classes :
> One implementation class, generated once, where I can write business code :
> - class EmployeeServiceBean extends  EmployeeServiceBase implements
> EmployeeServiceLocal
> One abstract base class, generated everytime I run mvn install :
> - abstract class EmployeeServiceBase implements EmployeeService
> And two interfaces, generated everytime too :
> - @javax.ejb.Local interface EmployeeServiceLocal extends EmployeeService
> - interface EmployeeService
> All public methods for a stateless EJB are declared in EmployeeServiceLocal
> interface, the other interface is supposed to define getter and setter
> methods for attributes of stateful session beans.
> I also have a ejb-jar.xml file with EJB defined as following :
> <session>
>     <ejb-name>EmployeeServiceBean</ejb-name>
>     <local>t4.core.employee.EmployeeServiceLocal</local>
>     <ejb-class>t4.core.employee.EmployeeServiceBean</ejb-class>
>     <session-type>Stateless</session-type>
>     <transaction-type>Container</transaction-type>
> </session>
> In a TestNG test class, I have the following code looking for the EJB
> session bean from its JNDI name :
> EmployeeServiceLocal employeeService = 
>     (EmployeeServiceLocal)
> getInitialContext().lookup("EmployeeServiceBean/Local");
> OpenEJB retrieves the EJB but I have a ClassCastException. I expected the
> EJB to be EmployeeServiceLocal typed (as it is the case in ejb-jar.xml), but
> it is EmployeeService typed ! It looks like OpenEJB doesn't retrieve
> interface of the implementation class, but interface from the base class. Is
> it something intended or is it a bug ? 
> Thanks in advance for your help ;)
> And congratulations for the good job made on OpenEJB. I tried to use other
> embedded containers (JBoss Embedded, Glassfish embedded, EJB3Unit, ...) and
> met so many bugs I could not make them work. I am not far to succeed with
> Open EJB !

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message