0 Replies Latest reply on Mar 6, 2003 12:09 PM by Fred Loney

    scoped classloader lookup ClassCastException

    Fred Loney Newbie

      I have two deployment units, app.war and ejb.ear. There is a Session Bean with remote home interface MyBeanHome.class. MyBeanHome.class occurs separately in two places:



      ejb.ear uses a jboss-app.xml scoped classloader in order to avoid jar version incompatibilities with the server. In app.war, the JNDI lookup call:

      Object obj = ctx.lookup("java:comp/env/ejb/MyBean");
      MyBeanHome home = (MyBeanHome)PortableRemoteObject.narrow(obj, MyBeanHome.class);

      fails with a ClassCastException. The JNDI reference is apparently set to an object that implements the MyBeanHome.class scoped by the ejb.ear classloader, which is distinct from the MyBeanHome.class scoped by the app.war classloader.

      This presents a dilemma: how can app.war obtain a MyBeanHome object? I.e., is it possible for a deployment unit to reference a remote Session Bean created by a separate ejb deployment unit that uses a scoped classloader?

      If so, then the implication is that a scoped classloader precludes the location transparency of remote Session Beans.