1 Reply Latest reply on Nov 3, 2005 8:31 AM by Adrian Brock

    Class Loading problem with EJB 2

    sys user Master

      JBoss 4.0.3
      JDK 1.4.2_08
      EJB 2

      I am currently experiencing some difficulties with the JBoss 4 class loader.

      We use xDoclet to generate Util class to help us lookup RemoteHome interfaces.
      Here is an example:

      private static Object lookupHome(java.util.Hashtable environment, String jndiName, Class narrowTo) throws javax.naming.NamingException {
       // Obtain initial context
       javax.naming.InitialContext initialContext = new javax.naming.InitialContext(environment);
       try {
       Object objRef = initialContext.lookup(jndiName);
       // only narrow if necessary
       if (narrowTo.isInstance(java.rmi.Remote.class))
       return javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo);
       return objRef;
       } finally {

      If I call this method with narrowTo be ObjectTypeServiceRemoteHome.class which extends
      javax.ejb.EJBHome (implementing java.rmi.Remote), the call to narrowTo.isInstance(java.rmi.Remote.class)
      returns false (even though narrowTo instanceof java.rmi.Remote is true).

      I'm starting to understand the new UCL3, but I'm still unclear why my JVM doesn't know that javax.ejb.EJBHome implements java.rmi.Remote. The java.rmi.Remote interface is only present in JAVA_HOME/../rt.jar and EJBHome is present in default/lib/jboss-j2ee.jar. Could someone tell me a way diagnose this issue? Do both ObjectTypeServiceRemoteHome and Remote have to be loaded by the same ClassLoader so ObjectTypeServiceRemoteHome.class.isInstance(java.rmi.Remote.class) return true?

      Any suggestion would be greatly appreciated.