ClassCastException within EAR - Stateless Session Bean interface flattening hierarchy
-------------------------------------------------------------------------------------
Key: EJBTHREE-1189
URL:
http://jira.jboss.com/jira/browse/EJBTHREE-1189
Project: EJB 3.0
Issue Type: Bug
Affects Versions: AS 4.2.0 GA
Environment: Win XP Prof, Java 2 Runtime Environment, Standard Edition (build
1.5.0_14-b03), Java HotSpot Client VM (build 1.5.0_14-b03, mixed mode, sharing)
Reporter: Ananda Debnath
Project structure
=============
DVS3.ear/
+-Util.jar (J2EE utility project)
| +-dvs3.Changelist (java interface)
|
+-Core.jar/ (EJB Project)
| +dvs3.code.session.ChangelistService (java interface that extends dvs3.Changelist)
| +dvs3.code.session.ChangelistServiceBean (stateless session bean that implements
ChangelistService)
|
+-WebUI.war/
| +dvs3.code.action.JSFBackingBean (a bbean that calls a session bean service via JNDI)
I'm assuming the manifest files are defined correctly since both Core.jar and Util.jar
are referenced in the WebUI.war manifest file and Util.jar is referenced in the Core.jar
manifest file.
In the backing bean, I have this piece of code:
String jndi = "DVS3EAR/ChangelistServiceBean/local";
Object service = new InitialContext().lookup(jndi);
System.out.println(service instanceof ChangelistService) // prints true
System.out.println(service instanceof Changelist) // prints false
Changelist service = (Changelist) obj; // fails with a
ClassCastException
Why is this?
At some level, isn't this violating a fundamental java principle? Since
ChangelistService is a Changelist, why can't I cast the service object to be a
Changelist, but can cast it to be of type ChangelistService?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira