Hello everyone-
I'm having difficulties getting the ConfigurationAdmin bundle to
work. I have a host application that starts a Felix container; it has
felix-1.6.1.jar and org.apache.felix.configadmin-1.0.10.jar in
CLASSPATH.
Installing the ConfigurationAdmin bundle into the container works
fine, and the services are registered, but trying to obtain the
service interface like this in a ServiceListener:
String[] objectClass = (String[]) event.getServiceReference
().getProperty(Constants.OBJECTCLASS);
ServiceReference servRef = context.getServiceReference(objectClass[0]);
ConfigurationAdmin configAdmin = (ConfigurationAdmin)
context.getService(servRef);
results in:
java.lang.ClassCastException:
org.apache.felix.cm.impl.ConfigurationAdminImpl
Intuitively that makes sense - It's returning an object loaded by a
different classloader, but the class ConfigurationAdmin is also in
the application class loader's classpath.
But both the host application and the bundle need to have the
ConfigurationAdmin class in the classpath, because both use it.
I see that the PermissionAdmin bundle seems to be able to avoid this,
but its manifest looks differently - it has no Import-Package, but an
Ignore-Package (which, just like Private-Package, doesn't seem to be
part of the spec, and isn't mentioned in the Maven Bundle plugin page).
So, how can I avoid this problem? I'm getting the feeling that
there's something quite basic that I'm not understanding about how
bundles work; any hint in the right direction would be much appreciated.
Many thanks in advance,
Ulf
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]