Github user aledsage commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/490#discussion_r93219658
--- Diff:
core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java ---
@@ -988,7 +988,7 @@ protected void setCatalogItemId(BrooklynObject item,
String catalogItemId) {
} catch (Exception e) {
Exceptions.propagateIfFatal(e);
}
- return new
ClassLoaderUtils(reflections.getClassLoader()).loadClass(jType);
+ return new ClassLoaderUtils(reflections.getClassLoader(),
managementContext).loadClass(jType);
--- End diff --
Without this, on rebind when it calls `ClassLoaderUtils.getFramework()` it
gets back null (i.e. the OSGi framework is not found). This is because
`FrameworkUtil.getBundle(ClassLoaderUtils.class)` does not find a bundle.
Looking at `ClassLoaderUtils.class.getClassLoader()`, it is
`sun.misc.Launcher$AppClassLoader@77abfbdc`.
Presumably this would not happen if we were running Karaf, but happens when
we just have the embedded felix container (i.e. in classic mode, and when
running testng unit tests).
Passing in the management context means `getFramework()` is able to instead
call `mgmt.getOsgiManager()`, and thus finds the OSGi `Framework`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---