Uploaded image for project: 'FUSE Services Framework'
  1. FUSE Services Framework
  2. SF-348

CXF should set the TCCL to the one of the service being invoked prior any invocation

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2.3.2-fuse-00-00
    • Component/s: None
    • Labels:
      None

      Description

      So a user has 2 bundles, each with a CXF webservice on the same port:

      bundle A - http://0.0.0.0:8080/A
      bundle B - http://0.0.0.0:8080/B

      Problem is that since they are using the same port, a single Jetty engine will be shared and each Jetty thread's class loader will be set to the classloader of whichever bundle started first. So, say bundle A started first, now the classloaders would be assigned as follows:

      bundle A - BundleDelegatingClassLoader for [bundle A]
      bundle B - BundleDelegatingClassLoader for [bundle A]

      Any incoming requests to the service in bundle B will use the classloader from bundle A, which is obviously not good

      So far I have three workarounds, none of which are a real fix:

      1. use a unique port for each bundle's web service so they get their own Jetty engine

      2. turn on dynamic imports for each bundle

      3. manually override the classloader before doing any work in a bundle
      ClassLoader oldCL = currentThread().getContextClassLoader();
      currentThread().setContextClassLoader(this.getClass().getClassLoader());
      try {
      // do some classloading
      } finally {
      Thread.currentThread().setContextClassLoader(oldCL);
      }

      So we should set the thread ContextClassLoader to the classloader of the service object before actually calling the service

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                willem.jiang Willem Jiang
                Reporter:
                janstey Jonathan Anstey
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: