ClassCastException while getting Home interface's reference
posted 10 years ago
I tried a "Hello world using EJB and Servlet" program. I am getting "ClassCastException" on the line: "testSessionBean = (MyTestSessionHome)PortableRemoteObject.narrow(objref,MyTestSessionHome.class);".
testSessionBean is of home type as expected.
I tried a lot to get the program right but couldn't get it.
Analysis of "objref" shows, though it implements MyTestSessionHome, is not an instance of MyTestSessionHome (?), but it's an instance of EJBHome. Actually both must be true.
Have a look at Debug ClassCastExceptions in JBoss. Specifically the jmx-console method mentioned over there. Looks like you have packaged the home/remote/local interfaces of the bean in more than one archives.