Stephan Siano created CAMEL-19794:
-------------------------------------
Summary: OsgiEventAdminNotifier not getting registered
Key: CAMEL-19794
URL: https://issues.apache.org/jira/browse/CAMEL-19794
Project: Camel
Issue Type: Bug
Components: camel-blueprint
Affects Versions: 3.21.0, 3.14.9
Reporter: Stephan Siano
Assignee: Grzegorz Grzybek
After an update from Camel 2.x to Camel 3.14.7 we noticed that the
OsgiEventAdminNotifier is not getting registered in Camel 3 blueprint contexts
(the same issue exists in all newer Camel 3 versions).
The reason for this is in the following code in
org.apache.camel.blueprint.CamelContextFactoryBean:
{code}
try {
getClass().getClassLoader().loadClass("org.osgi.service.event.EventAdmin");
getContext().getManagementStrategy().addEventNotifier(new
OsgiEventAdminNotifier(bundleContext));
} catch (Throwable t) {
// Ignore, if the EventAdmin package is not available, just don't
// use it
LOG.debug("EventAdmin package is not available, just don't use it");
}
{code}
The problem is that the camel-osgi-core bundle (where the class
OsgiEventAdminNotifier is located) has an optional import for
org.osgi.service.event, but the camel-blueprint bundle where the
CamelContextFactoryBean is located does not have this import.
I see two solutions for the issue:
either add the line
org.osgi.service.event;resolution:=optional,
to camel.osgi.import in the camel-blueprint pom
or change the above code to use the classloader of the camel-osgi-core bundle
to load the EventAdmin class in the code above:
{code}
OsgiEventAdminNotifier.class.getClassLoader().loadClass("org.osgi.service.event.EventAdmin");
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)