6 Replies Latest reply on Apr 25, 2003 8:36 AM by Kevin Self

    EJB Calls another EJB causes ClassCastException

    Kevin Self Newbie

      Hi to all,

      I have a very strange problem that I have tried to figure out. Here is the situation;

      I have an EJB, 'A', which calls another EJB, 'B'. EJB A is contained in one package and EJB B in another package and both are deployed seperately into the same Application Server.

      During the PortableRemoteObject.narrow call, I get a ClassCastException error message when trying to access the home interface for EJB B. The home and Remote interfaces for the EJB B are stored in a jar which was placed in the \lib\ext directory. If I do NOT put this Jar file here, then I get lots of other error messages related to not finding the classes. If I cast the home interface to an EJBHome interface through the narrow function (and not BHome), there is no ClassCastException error, so I know it is a home interface. What makes this even more strange is if I attempt to call the EJB B from a client application, it works fine. Lastly, this problem only appeared when I tried to move an existing application from JBoss 2.4.8 to JBoss 2.0.6 (The same problem exists for all versions of JBoss 3.0.x).

      From what I have read, I am guessing that the problem has something to do with the ClassLoader. I have checked for incorrect versions of the stub jar file that contains the home and remote interfaces for the EJB 'B' and none exist (the only one is in the \lib\ext directory). I am running JDK 1.4.1 on this machine, but this problem also appeared using the JDK1.4 also.

      Does anyone have any suggestions on where to look next to fix this problem?