glassfish
  1. glassfish
  2. GLASSFISH-12197

Unable to connect to GFv3.x.x via RMI/IIOP from Eclipse RCP client

    Details

    • Issuezilla Id:
      12,197

      Description

      As described in discussion thread (see URL), we are trying to connect to GFv3.x.x from an Eclipse RCP
      application using standalone-client approach with ProgrammaticLogin, as described in detail under
      http://ansis.com/know-how/software-development/glassfish/eclipse-rcp-standalone-client/ .

      Under GFv2.1.1 it is working flawlessly and under GFv3, we keep receiving the following exception
      when we lookup the SECOND session bean (it doesn't matter which bean is first on which is second,
      always the second produces this error):

      com.ansis.timetracker.server.exception.TTRuntimeException: Error looking up remote interface for:
      com.ansis.timetracker.server.session.remote.DashboardFacadeBeanRemote
      at com.ansis.timetracker.server.util.ConnectionDetails.lookup(ConnectionDetails.java:140)
      at
      com.ansis.timetracker.server.util.ConnectionDetails.getDashboardFacadeBean(ConnectionDetails.java:24
      2)
      at com.ansis.timetracker.client.ClientActivator.getDashboardFacadeBean(ClientActivator.java:906)
      at com.ansis.timetracker.client.ClientActivator.lookup(ClientActivator.java:890)
      at com.ansis.timetracker.client.ClientActivator.access$11(ClientActivator.java:886)
      at com.ansis.timetracker.client.ClientActivator$6.executeServerCommand(ClientActivator.java:757)
      at com.ansis.timetracker.client.core.Operation.run(Operation.java:59)
      at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
      Caused by: javax.naming.NamingException: Lookup failed for
      'com.ansis.timetracker.server.session.remote.DashboardFacadeBeanRemote' in SerialContext
      targetHost=localhost,targetPort=30037,orb'sInitialHost=localhost,orb'sInitialPort=3700 [Root exception
      is javax.naming.NamingException: ejb ref resolution error for remote business
      interfacecom.ansis.timetracker.server.session.remote.DashboardFacadeBeanRemote [Root exception is
      java.lang.RuntimeException: Could not invoke defineClass!]]
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at com.ansis.timetracker.server.util.ConnectionDetails.lookup(ConnectionDetails.java:138)
      ... 7 more
      Caused by: javax.naming.NamingException: ejb ref resolution error for remote business
      interfacecom.ansis.timetracker.server.session.remote.DashboardFacadeBeanRemote [Root exception is
      java.lang.RuntimeException: Could not invoke defineClass!]
      at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:430)
      at
      com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.j
      ava:70)
      at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
      at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:472)
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:437)
      ... 9 more
      Caused by: java.lang.RuntimeException: Could not invoke defineClass!
      at com.sun.corba.ee.impl.orbutil.codegen.CodeGeneratorUtil.makeClass(CodeGeneratorUtil.java:98)
      at com.sun.corba.ee.spi.orbutil.codegen.Wrapper._generate(Wrapper.java:1102)
      at com.sun.corba.ee.spi.orbutil.codegen.Wrapper._generate(Wrapper.java:1086)
      at com.sun.ejb.EJBUtils.generateAndLoad(EJBUtils.java:586)
      at com.sun.ejb.EJBUtils.loadGeneratedGenericEJBHomeClass(EJBUtils.java:538)
      at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:399)
      ... 13 more
      Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at com.sun.corba.ee.impl.orbutil.codegen.CodeGeneratorUtil.makeClass(CodeGeneratorUtil.java:95)
      ... 18 more
      Caused by: java.lang.LinkageError: loader (instance of
      org/eclipse/core/runtime/internal/adaptor/ContextFinder): attempted duplicate class definition for
      name: "com/sun/ejb/codegen/GenericEJBHome_Generated"
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
      ... 23 more

        Activity

        Hide
        Cheng Fang added a comment - - edited

        I tried the attached test app. There are a few place I needed to change:

        change the lookup name to:
        java:global/com.ansis.remoting.sample/com.ansis.remoting.sample.ejb/SessionBean1
        java:global/com.ansis.remoting.sample/com.ansis.remoting.sample.ejb/SessionBean2
        (note the module-name part now uses .,not _)

        Removed @Override in 2 bean class.

        the ejb project requires a library named GlassFish Server Open Source Edition, which doesn't exist in my eclipse. So I added a javax.ejb.jar to its build path.

        A couple of jars (among the many jars copied from gf/modules) no long exist in current GlassFish builds, and I had to remove them from the dependency list to be able to build the client project.

        Added ssl-impl.jar and glassfish-corba-internal-api.jar to the dependency list in MANIFEST.MF.

        Also changed java.naming.factory.initial to com.sun.enterprise.naming.impl.SerialInitContextFactory. I also tried the no-arg InitialContext(), but haven't seen any difference.

        With these changes I was able to build and deploy the EAR. When running the client, got the following error, similar to yours:

        Dec 7, 2010 11:04:24 PM com.sun.logging.LogDomains$1 log
        INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.
        Dec 7, 2010 11:04:25 PM com.sun.logging.LogDomains$1 log
        INFO: DTX5019: Using [com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate] as the delegate
        javax.naming.NamingException: Lookup failed for 'java:global/com.ansis.remoting.sample/com.ansis.remoting.sample.ejb/SessionBean2' in SerialContext[targetHost=null,targetPort=null [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.ansis.remoting.sample.ejb.Session2Remote [Root exception is java.lang.RuntimeException: Could not invoke defineClass!]]
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:561)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at com.ansis.remoting.sample.eclipse.client.actions.SampleAction.lookupBothBeans(SampleAction.java:65)
        at com.ansis.remoting.sample.eclipse.client.actions.SampleAction.run(SampleAction.java:43)
        at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
        at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
        at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
        at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
        at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3776)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1367)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1390)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
        at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1187)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3622)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3277)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
        at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
        Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.ansis.remoting.sample.ejb.Session2Remote [Root exception is java.lang.RuntimeException: Could not invoke defineClass!]
        at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:434)
        at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:75)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:595)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:557)
        ... 38 more
        Caused by: java.lang.RuntimeException: Could not invoke defineClass!
        at com.sun.corba.ee.impl.orbutil.codegen.CodeGeneratorUtil.makeClass(CodeGeneratorUtil.java:102)
        at com.sun.corba.ee.spi.orbutil.codegen.Wrapper._generate(Wrapper.java:1103)
        at com.sun.corba.ee.spi.orbutil.codegen.Wrapper._generate(Wrapper.java:1087)
        at com.sun.ejb.EJBUtils.generateAndLoad(EJBUtils.java:590)
        at com.sun.ejb.EJBUtils.loadGeneratedGenericEJBHomeClass(EJBUtils.java:542)
        at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:403)
        ... 42 more
        Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.corba.ee.impl.orbutil.codegen.CodeGeneratorUtil.makeClass(CodeGeneratorUtil.java:99)
        ... 47 more
        Caused by: java.lang.LinkageError: loader (instance of org/eclipse/core/runtime/internal/adaptor/ContextFinder): attempted duplicate class definition for name: "com/sun/ejb/codegen/GenericEJBHome_Generated"
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        ... 52 more

        Show
        Cheng Fang added a comment - - edited I tried the attached test app. There are a few place I needed to change: change the lookup name to: java:global/com.ansis.remoting.sample/com.ansis.remoting.sample.ejb/SessionBean1 java:global/com.ansis.remoting.sample/com.ansis.remoting.sample.ejb/SessionBean2 (note the module-name part now uses .,not _) Removed @Override in 2 bean class. the ejb project requires a library named GlassFish Server Open Source Edition, which doesn't exist in my eclipse. So I added a javax.ejb.jar to its build path. A couple of jars (among the many jars copied from gf/modules) no long exist in current GlassFish builds, and I had to remove them from the dependency list to be able to build the client project. Added ssl-impl.jar and glassfish-corba-internal-api.jar to the dependency list in MANIFEST.MF. Also changed java.naming.factory.initial to com.sun.enterprise.naming.impl.SerialInitContextFactory. I also tried the no-arg InitialContext(), but haven't seen any difference. With these changes I was able to build and deploy the EAR. When running the client, got the following error, similar to yours: Dec 7, 2010 11:04:24 PM com.sun.logging.LogDomains$1 log INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default. Dec 7, 2010 11:04:25 PM com.sun.logging.LogDomains$1 log INFO: DTX5019: Using [com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate] as the delegate javax.naming.NamingException: Lookup failed for 'java:global/com.ansis.remoting.sample/com.ansis.remoting.sample.ejb/SessionBean2' in SerialContext[targetHost=null,targetPort=null [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.ansis.remoting.sample.ejb.Session2Remote [Root exception is java.lang.RuntimeException: Could not invoke defineClass!] ] at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:561) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491) at javax.naming.InitialContext.lookup(InitialContext.java:392) at com.ansis.remoting.sample.eclipse.client.actions.SampleAction.lookupBothBeans(SampleAction.java:65) at com.ansis.remoting.sample.eclipse.client.actions.SampleAction.run(SampleAction.java:43) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3776) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1367) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1390) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1187) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3622) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3277) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574) at org.eclipse.equinox.launcher.Main.run(Main.java:1407) at org.eclipse.equinox.launcher.Main.main(Main.java:1383) Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.ansis.remoting.sample.ejb.Session2Remote [Root exception is java.lang.RuntimeException: Could not invoke defineClass!] at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:434) at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:75) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:595) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:557) ... 38 more Caused by: java.lang.RuntimeException: Could not invoke defineClass! at com.sun.corba.ee.impl.orbutil.codegen.CodeGeneratorUtil.makeClass(CodeGeneratorUtil.java:102) at com.sun.corba.ee.spi.orbutil.codegen.Wrapper._generate(Wrapper.java:1103) at com.sun.corba.ee.spi.orbutil.codegen.Wrapper._generate(Wrapper.java:1087) at com.sun.ejb.EJBUtils.generateAndLoad(EJBUtils.java:590) at com.sun.ejb.EJBUtils.loadGeneratedGenericEJBHomeClass(EJBUtils.java:542) at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:403) ... 42 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.corba.ee.impl.orbutil.codegen.CodeGeneratorUtil.makeClass(CodeGeneratorUtil.java:99) ... 47 more Caused by: java.lang.LinkageError: loader (instance of org/eclipse/core/runtime/internal/adaptor/ContextFinder): attempted duplicate class definition for name: "com/sun/ejb/codegen/GenericEJBHome_Generated" at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) ... 52 more
        Hide
        Cheng Fang added a comment -

        GlassFish ejb impl relies on thread context class loader to load and generate classes. But the client side equinox framework doesn't have a distinct notion of TCCL. Instead it uses org.eclipse.core.runtime.internal.adaptor.ContextFinder as a kind of meta loader, which chooses to delegate to each bundle's loader.

        ContextFinder in EJBUtils as TCCL, cannot load the previously-generated class com/sun/ejb/codegen/GenericEJBHome_Generated, probalby because this class does not belong to any bundles. However, the class is indeed already loaded by the first look, hence the second attempt to generate it has failed with LinkageError.

        If I wrap the lookup operations with TCCL switch, it works smoothly:

        try {
        InitialContext context = new InitialContext();

        ClassLoader contextFinder = Thread.currentThread().getContextClassLoader();
        ClassLoader ejbUtilsClassLoader = EJBUtils.class.getClassLoader();
        System.out.println("### EJBUtils loader: " + ejbUtilsClassLoader);
        System.out.println("### Context loader:" + contextFinder);

        Thread.currentThread().setContextClassLoader(EJBUtils.class.getClassLoader());
        Session1Remote bean1 = null;
        Session2Remote bean2 = null;

        try

        { bean1 = (Session1Remote) context .lookup("java:global/com.ansis.remoting.sample/com.ansis.remoting.sample.ejb/SessionBean1"); System.out.println("bean1: " + bean1 + ", bean1.helloWorld(): " + bean1.helloWorld()); bean2 = (Session2Remote) context .lookup("java:global/com.ansis.remoting.sample/com.ansis.remoting.sample.ejb/SessionBean2"); System.out.println("bean2: " + bean2 + ", bean2.helloWorld(): " + bean2.helloWorld()); }

        finally

        { Thread.currentThread().setContextClassLoader(contextFinder); }

        return bean2.helloWorld();
        } catch (final NamingException e)

        { e.printStackTrace(); return "Error"; }

        The output from running the sample action:

        Dec 8, 2010 3:19:05 PM com.sun.logging.LogDomains$1 log
        INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.

            1. EJBUtils loader: org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@4d83c7a0
            2. Context loader:org.eclipse.core.runtime.internal.adaptor.ContextFinder@722cb5c6
              Dec 8, 2010 3:19:06 PM com.sun.logging.LogDomains$1 log
              INFO: DTX5019: Using [com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate] as the delegate

        bean1: com.ansis.remoting.sample.ejb._Session1Remote_Wrapper@1757156, bean1.helloWorld(): Hello from Session Bean 1

        bean2: com.ansis.remoting.sample.ejb._Session2Remote_Wrapper@365bac97, bean2.helloWorld(): Hello from Session Bean 2

        If there is a way to disable ContextFinder, then the TCCL works as expected and we don't even need to add that context switch in application code.

        Show
        Cheng Fang added a comment - GlassFish ejb impl relies on thread context class loader to load and generate classes. But the client side equinox framework doesn't have a distinct notion of TCCL. Instead it uses org.eclipse.core.runtime.internal.adaptor.ContextFinder as a kind of meta loader, which chooses to delegate to each bundle's loader. ContextFinder in EJBUtils as TCCL, cannot load the previously-generated class com/sun/ejb/codegen/GenericEJBHome_Generated, probalby because this class does not belong to any bundles. However, the class is indeed already loaded by the first look, hence the second attempt to generate it has failed with LinkageError. If I wrap the lookup operations with TCCL switch, it works smoothly: try { InitialContext context = new InitialContext(); ClassLoader contextFinder = Thread.currentThread().getContextClassLoader(); ClassLoader ejbUtilsClassLoader = EJBUtils.class.getClassLoader(); System.out.println("### EJBUtils loader: " + ejbUtilsClassLoader); System.out.println("### Context loader:" + contextFinder); Thread.currentThread().setContextClassLoader(EJBUtils.class.getClassLoader()); Session1Remote bean1 = null; Session2Remote bean2 = null; try { bean1 = (Session1Remote) context .lookup("java:global/com.ansis.remoting.sample/com.ansis.remoting.sample.ejb/SessionBean1"); System.out.println("bean1: " + bean1 + ", bean1.helloWorld(): " + bean1.helloWorld()); bean2 = (Session2Remote) context .lookup("java:global/com.ansis.remoting.sample/com.ansis.remoting.sample.ejb/SessionBean2"); System.out.println("bean2: " + bean2 + ", bean2.helloWorld(): " + bean2.helloWorld()); } finally { Thread.currentThread().setContextClassLoader(contextFinder); } return bean2.helloWorld(); } catch (final NamingException e) { e.printStackTrace(); return "Error"; } The output from running the sample action: Dec 8, 2010 3:19:05 PM com.sun.logging.LogDomains$1 log INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default. EJBUtils loader: org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@4d83c7a0 Context loader:org.eclipse.core.runtime.internal.adaptor.ContextFinder@722cb5c6 Dec 8, 2010 3:19:06 PM com.sun.logging.LogDomains$1 log INFO: DTX5019: Using [com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate] as the delegate bean1: com.ansis.remoting.sample.ejb._Session1Remote_Wrapper@1757156, bean1.helloWorld(): Hello from Session Bean 1 bean2: com.ansis.remoting.sample.ejb._Session2Remote_Wrapper@365bac97, bean2.helloWorld(): Hello from Session Bean 2 If there is a way to disable ContextFinder, then the TCCL works as expected and we don't even need to add that context switch in application code.
        Hide
        Sanjeeb Sahoo added a comment -

        This looks like a bug in Equinox's special classloader called ContextFinder [1] which is used by Equinox as the TCCL to help run OSGi-unaware code inside Equinox. This class loader is not calling findLoadedClass(className) before attempting to load the class. I suggest you file a bug against equinox. Ask RCP users to find some work around from equinox forum.

        [1] http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhancements

        Show
        Sanjeeb Sahoo added a comment - This looks like a bug in Equinox's special classloader called ContextFinder [1] which is used by Equinox as the TCCL to help run OSGi-unaware code inside Equinox. This class loader is not calling findLoadedClass(className) before attempting to load the class. I suggest you file a bug against equinox. Ask RCP users to find some work around from equinox forum. [1] http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhancements
        Hide
        Cheng Fang added a comment -

        The issue lies in equinox and user application configuration. So close it as Won't Fix.

        Show
        Cheng Fang added a comment - The issue lies in equinox and user application configuration. So close it as Won't Fix.
        Hide
        Cheng Fang added a comment -

        Some corrections to my previous comment. As Sahoo commented, the problem is in Equinox ContextFinder. Besides exploring a fix in Equinox, you may also want to try configuring your application to work around it. After all, the context class loader switch in app code is cumbersome.

        Show
        Cheng Fang added a comment - Some corrections to my previous comment. As Sahoo commented, the problem is in Equinox ContextFinder. Besides exploring a fix in Equinox, you may also want to try configuring your application to work around it. After all, the context class loader switch in app code is cumbersome.

          People

          • Assignee:
            Cheng Fang
            Reporter:
            ansis
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: