Вопрос

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?

Это было полезно?

Решение

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)

That first bundle you listed, 0, that is exporting useradmin, I suspect isn't actually exporting anything. The second one is exporting a completely unrelated package. The third one is exporting the actual useradmin API. And the fourth one is exporting the apache felix specific classes.

Karaf doesn't actually contain the useradmin package anywhere in the standard download.

apache-karaf-2.3.3 sartrip -> gfind -iname \*jar | parallel unzip -l {}  | grep userad
    0  01-23-13 14:59   org/osgi/jmx/service/useradmin/
 4462  01-23-13 14:59   org/osgi/jmx/service/useradmin/UserAdminMBean.class
  822  01-23-13 14:59   org/osgi/jmx/service/useradmin/packageinfo
    0  02-08-13 11:24   org/apache/aries/jmx/useradmin/
12187  02-08-13 11:24   org/apache/aries/jmx/useradmin/UserAdmin.class
 1828  02-08-13 11:24   org/apache/aries/jmx/useradmin/UserAdminMBeanHandler.class

That means you must install the a bundle containing the useradmin API, either by installing the OSGI compendium API bundle or building your own JAR containing just the parts you want (org.osgi.service.useradmin).

EDIT:

I'll also point out that the not-yet-released version of apache felix useradmin will contain the org.osgi.service.useradmin (as it should!) meaning eventually your dependency on the compendium API jar will go away. https://github.com/apache/felix/blob/trunk/useradmin/useradmin/pom.xml#L81

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top