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 Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Done
    • Affects Version/s: 2.3.2-fuse-00-00
    • Component/s: None
    • Labels:
      None
    • Similar Issues:
      Show 9 results 

      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

        Activity

        Hide
        Willem Jiang
        added a comment -

        These two bundle CXF services share the same port, which means they are the same thread pool.
        so if there is one request for the BundleA services, the TCCL will be set to bundle A, and the if the thread server for other request for the BundleB, the TCCL will not be changed.

        CXF-3497 will make sure the application Classloader will be set as a bus extension and CXF will use the Classloader when it send the request to the server or handle the request from the transport.

        Show
        Willem Jiang
        added a comment - These two bundle CXF services share the same port, which means they are the same thread pool. so if there is one request for the BundleA services, the TCCL will be set to bundle A, and the if the thread server for other request for the BundleB, the TCCL will not be changed. CXF-3497 will make sure the application Classloader will be set as a bus extension and CXF will use the Classloader when it send the request to the server or handle the request from the transport.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: