Boot delegation packages

Boot delegation packages

Set the boot delegation packages

You can use the option --bootDelegation to specify java packages for which the Framework must delegate class loading to the boot class path.

pax-run --bootDelegation=<packages>

where packages must comply to ops4j:OSGi Alliance specs for org.osgi.framework.bootdelegation system property value.

You can use --bd as an alias for --bootDelegation
This feature is only available starting with release 0.8.0 of Pax Runner.

Example

pax-run --bootDelegation=sun.*,com.sun.*

to instruct the Framework that he must delegate all java.*, sun.* and com.sun.* packages to the parent class loader.

OSGi Alliance specs

Parent Delegation

The Framework must always delegate any package that starts with java. to the parent class loader.
Certain Java virtual machines, also SUN's VMs, appear to make the erroneous assumption that the delegation to the parent class loader always occurs. This implicit assumption of strictly hierarchical class loader delegation can result in NoClassDefFoundErrors. This happens if the virtual machine implementation expects to find its own implementation classes from any arbitrary class loader, requiring that packages loaded from the boot class loader not be restricted to only the java.* packages.
Other packages that must be loaded from the boot class loader can therefore be specified with the System property:

org.osgi.framework.bootdelegation

This property must contain a list with the following format:

org.osgi.framework.bootdelegation ::= boot-description ( ',' boot-description )* boot-description::= package-name | ( package-name '.*' ) | '*'

The .* wildcard means deep matching. Packages that match this list must be loaded from the parent class loader. The java.* prefix is always implied; it does not have to be specified.
The single wildcard means that the Framework must always delegate to the parent class loader first, which is the same as the Release 3 behavior. For example, when running on a SUN JVM, it may be necessary to specify a value like:

org.osgi.framework.bootdelegation=sun.*,com.sun.*

With such a property value, the Framework must delegate all java.*, sun.* and com.sun.* packages to the parent class loader.