How to resolve OSGi bundle startup NoClassDefFoundError errors using boot delegation?

How to resolve OSGi bundle startup NoClassDefFoundError errors using boot delegation?

Problem

OSGi bundles or plugins may fail to resolve or start, affecting application startup. The following errors may be displayed in the terminal output or application error logs:

"java.lang.NoClassDefFoundError: com/manageengine/apminsight/agent/JavaAgent"
A ClassNotFoundException for any com.manageengine.* class is the same issue.

Cause

OSGi bundles run in isolated class loaders and may not be able to access JVM-internal packages or externally injected classes, such as those provided by monitoring agents, unless the required packages are explicitly boot-delegated to the parent class loader.

When boot delegation is not configured or is configured incorrectly, the OSGi framework cannot access the APM Insight Java agent classes because the agent package is not included in the boot delegation configuration. This causes the OSGi bundle or plugin to fail to resolve or start.

Solution

Add the APM Insight Java agent package, com.manageengine.*, to the existing boot delegation Java property.

For example:
Info
-Dorg.osgi.framework.bootdelegation=com.sun.*,com.manageengine.*
Alert
Append com.manageengine.* to the existing boot delegation values. Do not remove the existing values.
Platform-specific configuration

Platform-specific configuration

The platform-specific properties and configuration locations are listed in the source document.

Platform
Property
Configuration location
Liferay DXP
module.framework.properties.org.osgi.framework.bootdelegation
portal-ext.properties
Atlassian Jira/Confluence
-Datlassian.org.osgi.framework.bootdelegation.extra
setenv.sh
Adobe Experience Manager (Sling)
-Dorg.osgi.framework.bootdelegation
sling.properties
Other OSGi platforms/bundled applications
-Dorg.osgi.framework.bootdelegation
Startup script, existing JAVA_OPTS, or another location where Java properties are maintained

Restart the application

After adding the com.manageengine.* package to the appropriate boot delegation property, restart the application server for the changes to take effect.

Summary

If an OSGi-based application fails to start with a NoClassDefFoundError or ClassNotFoundException error message for an APM Insight Java agent class, verify that com.manageengine.* has been added to the platform’s existing boot delegation configuration.