Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The common delegation mechanism for classloaders is to delegate to the parent first when loading a class. Thus, all classes defined in the container classloader are shared. But when a class references another class (using an import statement in the Java code for example), the referenced classes will be loaded by the same classloader. To avoid such problems, you can use a self-first delegation where classes are loaded from the classloader, and if not found, it will ask its parent.

In the service's POM.XML

Code Block
langxml

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.servicemix.tooling</groupId>
      <artifactId>jbi-maven-plugin</artifactId>
      <configuration>
        <classLoaderDelegation>self-first</classLoaderDelegation>
      </configuration>
    </plugin>
  </plugins>
</build>

SU Classloaders

XBean based service units can define their own classloader. This can be done by adding the following tag in the main XBean configuration file for the SU (xbean.xml or servicemix.xml for the servicemix-lwcontainer component):

...