1. glassfish
  2. GLASSFISH-21050

Problem with classloader and casting using osgi gf-client-module to access remote EJB (RMI) from GF4.


    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 4.0
    • Fix Version/s: None
    • Component/s: OSGi
    • Labels:
    • Environment:

      Server:centos 6.4, 64, openjdk 7
      Client:centos 6.4, 64, openjdk 7


      I have server-client architecture. Server and client different machines in one local network. Both server and client are on osgi framework. For server it's hybrid EJB. There are three osgi bundles:for server,for client and shared. The copy of shared is both on server and on clients and contains LanguageDirBeanRemote and LanguageDirEntity. To get my bean I use the following code on osgi-client:

      ClassLoader thatLoader = Thread.currentThread().getContextClassLoader();
      try {
      Properties jndiProps = new Properties();
      jndiProps.put("java.naming.factory.initial", "com.sun.enterprise.naming.impl.SerialInitContextFactory");
      jndiProps.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
      jndiProps.put("java.naming.factory.state", "");
      jndiProps.setProperty("org.omg.CORBA.ORBInitialHost", "x.x.x.x");
      jndiProps.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
      InitialContext ctx = new InitialContext(jndiProps);
      LanguageDirBeanRemote bean=(LanguageDirBeanRemote)ctx.lookup("java:global/...");
      ArrayList<LanguageDirEntity> elements=bean.readDirectory();
      System.out.println("HERE I GET THE ERROR:"+elements.get(0).getContent());
      } finally {

      Here is the log:
      java.lang.ClassCastException: com.test.cmn.shd.base.dir.language.LanguageDirEntity cannot be cast to com.test.cmn.shd.base.dir.language.LanguageDirEntity at com.test.cmn.dt.base.Activator.start( at org.apache.felix.framework.util.SecureAction.startActivator( at org.apache.felix.framework.Felix.activateBundle( at org.apache.felix.framework.Felix.startBundle( at org.apache.felix.framework.BundleImpl.start( at org.apache.felix.framework.BundleImpl.start( at com.test.cmn.dt.loader.LoaderModel.startCoreModule( at com.test.cmn.dt.loader.LoaderModel.access$100( at com.test.cmn.dt.loader.LoaderModel$InstallAndStartModuleWorker.doInBackground( at com.test.cmn.dt.loader.LoaderModel$InstallAndStartModuleWorker.doInBackground( at javax.swing.SwingWorker$ at at at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$ at

      The reason that I think it's the bug is that the following code works without any problems:
      LanguageDirEntity[] elements=bean.readDirectoryAsArray();
      We see, that using simple array, without ArrayList we get no errors. But when I try to use ArrayList or ArrayList<LanguageDirEntity> I get ClassCastException. I think the problem is somewhere in RMI when it loads classes.
      This prblem I also described on stackoverflow.


        There are no comments yet on this issue.


          • Assignee:
            Sanjeeb Sahoo
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created: