When a Java user-defined node is packaged as a PAR file, the Java user-defined node is loaded in a separate classloader.
The classloader loads any class that is packaged within the deployed PAR file. The classes that are placed in the JAR file override any classes that are in the shared classes directory or the CLASSPATH environment variable. If the deployed PAR file contains more than one node type, the nodes share the same classloader. Therefore, a set of user-defined nodes that share static data must be packaged in a single PAR file.
Java user-defined nodes that are packaged as simple JAR files are loaded in the same classloader. The classes and the location from which they are loaded are written to user trace, therefore you can use this information to check that the correct classes are being loaded.
The broker uses the following classloader tree:
The shared classloader also loads context
classes. It uses the CLASSPATH and the WorkPath/shared-classes/ directory
to search for classes.
The broker classloader and the shared classloader are children of the common classloader. Therefore, the contents of the shared classloader are not visible to the broker classloader. Do not store the following resources in this directory:
User-defined nodes package in a PAR file
User-defined nodes package in a JAR file
The endorsed standards overriding mechanism allows the following standard packages to be overridden in the JRE:
To override these packages in the broker, place the JAR files for the API standards in the /lib directory of the PAR file.
When looking up a JNDI context, the context classloader is used. If the lookup uses classes that are packaged with the user-defined node, the context classloader must be the same as the classloader that is being used to load the user-defined node. To ensure that each thread uses the same classloader, the following code can be included in the user-defined node class:
Thread.currentThread.setContextClassLoader(this.getClass().getClassLoader());