I am trying to install and start the Apache Felix implementation of the OSGi UserAdmin interface in Karaf 2.3.3.
karaf@root> install mvn:org.apache.felix/org.apache.felix.useradmin/1.0.3
However, the bundle never gets resolved and I get the following error on start:
Unable to start bundle 89: Activator start error in bundle org.apache.felix.useradmin [89].
[...]
Caused by: java.lang.NoClassDefFoundError: org.osgi.service.useradmin.UserAdminListener
at org.apache.felix.useradmin.osgi.UserAdminListenerListHelper.class$(UserAdminListenerListHelper.java:38)
at org.apache.felix.useradmin.osgi.UserAdminListenerListHelper.<init>(UserAdminListenerListHelper.java:38)
at org.apache.felix.useradmin.osgi.Activator.createServiceContext(Activator.java:68)
at org.apache.felix.useradmin.osgi.Activator.start(Activator.java:37)
at org.apache.felix.framework.util.SecureAction$Actions.run(SecureAction.java:1605)
at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_51]
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:636)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
... 16 more
As I read in this thread from the Karaf mailing list, Karaf already embeds the OSGi Compendium API but doesn't export all packages by default. I changed the config.properties
file to explicitly export the UserAdmin package:
org.osgi.framework.system.packages= \
[...]
org.osgi.service.permissionadmin;uses:="org.osgi.framework";version="1.1", \
org.osgi.service.useradmin;uses:="org.osgi.framework";version="1.1", \
[...]
The package org.osgi.service.useradmin
seems to be exported by Karaf, as I can see upon running packages:exports
.
I kept getting the error until I removed the line from the config file and deployed the OSGi Compendium API bundle as suggested in this other thread.
However, embedding the complete Compendium API seems somewhat overkill to me (though I may be wrong). And I now have 4 bundles exporting the UserAdmin package:
karaf@root> packages:exports | grep useradmin
0 # org.osgi.service.useradmin; version=1.1.0
20 org.osgi.jmx.service.useradmin; version=1.1.0
82 org.osgi.service.useradmin; version=1.1.0 --> OSGi Compendium osgi.cmpn (5.0.0.201305092017)
89 org.apache.felix.useradmin; version=1.0.0 --> Apache Felix User Admin Service (1.0.3)
Do you know of a better/simpler way to achieve this?