[jboss-user] [EJB 3.0] - ClassCastException within an EAR deployment
heizenberg
do-not-reply at jboss.com
Fri Feb 8 15:03:43 EST 2008
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 (stlss sess 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?
Is this some kind of weird (but legal) classloading?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127970#4127970
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127970
More information about the jboss-user
mailing list