Uploaded image for project: 'Application Server 7'
  1. Application Server 7
  2. AS7-2165

Thread context ClassLoader set to unexpected value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.1.0.Beta1
    • 7.0.2.Final
    • OSGi
    • Hide

      Attached is a simple Maven project to build and deploy a reproducer. Unzip this project and:

      mvn clean package jboss-as:deploy

      The bundle activator has several System.out.println() statements to show the status of resolved resources.

      For comparison, do this in both 7.0.2 and 7.0.1 and note the difference in behavior.

      Show
      Attached is a simple Maven project to build and deploy a reproducer. Unzip this project and: mvn clean package jboss-as:deploy The bundle activator has several System.out.println() statements to show the status of resolved resources. For comparison, do this in both 7.0.2 and 7.0.1 and note the difference in behavior.

      I am using library code in a BundleActivator that tries to load resources via ClassLoader. The logic in the library looks something like this:

      1. if thread context ClassLoader exists use it
      2. else use ClassLoader for this class

      The thread context ClassLoader differs from the class ClassLoader. The resources packaged in my bundle are not available to the thread context ClassLoader, but they are available to the class ClassLoader. In 7.0.1 there was no thread context ClassLoader, so the library code used the class ClassLoader and correctly loaded the resources.

      Here's what toString on the thread context ClassLoader shows:

      ModuleClassLoader for Module "org.jboss.as.osgi:main" from local module loader @67d225a7 (roots: /Users/tpesce/Developer/jboss-as-7.0.2.Final/modules)

      Here's the toString on the class ClassLoader:

      HostBundleClassLoader for Module "deployment.jboss.osgi.bug:1.0.0" from Service Module Loader

              tdiesler@redhat.com Thomas Diesler
              tpesce_jira Tim Pesce (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: