4 Replies Latest reply on Apr 22, 2011 12:13 PM by xbbrck

    Incorrect context classloader

    xbbrck

      Hello,

       

      I have a very annoying issue with my context class-loader when I have multiple bundles in my Fuse ESB.

       

      I have several custom bundles (spring), of which:

      [[ 227]] [[Active     ]] [[            ]] [[Started]] [[   80]] Thaler API OSGI Bundle (1.0.0.SNAPSHOT)

      [[ 236]] [[Active     ]] [[            ]] [[Started]] [[   90]] Parameter Web Service (1.0.0.SNAPSHOT)

       

      I have a camel route in bundle 236 that calls a bean that needs the context class-loader (for jpa).  I always got a class not found exception, and when I added the following logging to the bean it was very obvious why:

              ClassLoader oldCL = currentThread().getContextClassLoader();

              log.debug("Old class Loader: " + oldCL);

       

      The result:

      236 - be.mensura.service.param - 1.0.0.SNAPSHOT | Old class Loader: BundleDelegatingClassLoader for [[Thaler API OSGI Bundle (be.mensura.service.thaler)]]

       

      As you can see, bundle 236 got the context class-loader of bundle 227.  I can tell you, these bundles aren't related in any way.

       

      Does anybody have a similar problem?  I have a workaround, but I'm really not happy with it, especially because OSGi is supposed to solve this.  I have a Fuse Support case, but they remain very silent lately.

       

      I was thinking of switching to Karaf as OSGi implementation and see if its helps.  Does anybody has experience with that?  What is your conclusion?  I'm using Fuse ESB 4.3.1.

       

      Kind regards,

      Bryan.

        • 1. Re: Incorrect context classloader
          njiang

          Hi,

           

          Spring DM will set the TCCL with the bundle that has the camel context.

          Is there any code in the Thaler API OSGI Bundle that reset the TCCL ?

           

          BTW, I don't think switch to the Karaf can resolve the issue that you faced.

           

          Willem

          • 2. Re: Incorrect context classloader
            xbbrck

            The Thaler bundle is party 3th party code, so I don't know exactly what happens there.  I know it is a JCA library.

             

            But, even when the Thaler bundle does change the TCCL I don't see how that can affect the Param bundle?  Even when the Thaler bundle set a different TCCL it will not be the Spring DM bundle classloader.  Also, how could the Thaler bundle change the TCCL of a Param bundle thread?

            I do know for a fact that Param does not change the TCCL, this bundle is 100% own code and standard Fuse ESB bundles.

             

            Do you think using blueprint instead of Spring would help?

            • 3. Re: Incorrect context classloader
              njiang

              What about when the Param bundle calls a method of the Thaler bundle, the method changes TCCL and never reset the TCCL back?

               

              In this case you have to set the TCCL back in the Param bundle if you can not change the codes of Thaler bundle.

               

              Willem

              • 4. Re: Incorrect context classloader
                xbbrck

                Hello,

                 

                As indicated in the original message, the bundles are totally independent.  The bundles do not call methods from each other.  I'm 100% sure about this, because when I deploy a single bundles each of them work perfectly.