0 Replies Latest reply on Aug 21, 2007 5:24 PM by Dan Wiebe

    Another deployment ClassCastException

    Dan Wiebe Newbie

      I've got a JEE 5.2 application that ran fine under Glassfish that I'm trying to regress to run under JBoss 4.2.1.GA (because while Glassfish may completely implement EE 5, it's exasperatingly unstable).

      I've read a number of complaints about ClassCastExceptions involved with JNDI lookups, and how they're related either to the lack of a .../remote or .../local suffix on the JNDI name, or to classes loaded by different classloaders. I've tried to take care of all that. Here's (part of) my global JNDI namespace:

       +- BackEnd (class: org.jnp.interfaces.NamingContext)
       | +- GeneralService (class: org.jnp.interfaces.NamingContext)
       | | +- remote (proxy: $Proxy97 implements interface pkg.GeneralService,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)

      I recognize the stuff in bold: that's my stuff. I'm careful to use the JNDI name only with the .../remote suffix, so as to grab something that's compatible with my GeneralService interface.

      But during deployment, I get this exception when I try to cast the result of InitialContext.lookup () to pkg.GeneralService:

      java.lang.ClassCastException: $Proxy97 cannot be cast to pkg.GeneralService

      Can't be cast to it? But the JNDI catalog says $Proxy97 implements it! What's going on? Is this an instance of the classloader incompatibility? Why would JBoss be written to use two different classloaders in the process of loading an EJB from JNDI?