Platform: debian 9.5 "stretch", amd64
          openjdk-8-jdk 8u181-b13-1~deb9u1
          karaf 4.1.5

(Note: This is a project very much in the start phase so I haven't pushed
anything to github yet)

I'm trying to inject a SystemMBean into a DS component.  When I try
this, loading the feature holding the component, fails with an error
message:
 karaf@root()> feature:repo-add 
mvn:no.priv.bang.neo4j.karaf/neo4j-karaf/LATEST/xml/features
 Adding feature url mvn:no.priv.bang.neo4j.karaf/neo4j-karaf/LATEST/xml/features
 karaf@root()> feature:install neo4j-server
 Error executing command: Unable to resolve root: missing requirement [root] 
osgi.identity; osgi.identity=neo4j-server; type=karaf.feature; 
version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; 
filter:="(&(osgi.identity=neo4j-server)(type=karaf.feature)(version>=1.0.0.SNAPSHOT)(version<=1.0.0.SNAPSHOT))"
 [caused by: Unable to resolve neo4j-server/1.0.0.SNAPSHOT: missing requirement 
[neo4j-server/1.0.0.SNAPSHOT] osgi.identity; 
osgi.identity=no.priv.bang.neo4j.karaf; type=osgi.bundle; 
version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; resolution:=mandatory [caused by: 
Unable to resolve no.priv.bang.neo4j.karaf/1.0.0.SNAPSHOT: missing requirement 
[no.priv.bang.neo4j.karaf/1.0.0.SNAPSHOT] osgi.service; 
filter:="(objectClass=org.apache.karaf.system.management.SystemMBean)"; 
effective:=active]]
 karaf@root()>

The karaf.log has this:
 2018-09-09T14:22:47,172 | ERROR | Karaf local console user karaf | ShellUtil   
                     | 43 - org.apache.karaf.shell.core - 4.1.5 | Exception 
caught while executing command
org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing 
requirement [root] osgi.identity; osgi.identity=neo4j-server; 
type=karaf.feature; version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; 
filter:="(&(osgi.identity=neo4j-server)(type=karaf.feature)(version>=1.0.0.SNAPSHOT)(version<=1.0.0.SNAPSHOT))"
 [caused by: Unable to resolve neo4j-server/1.0.0.SNAPSHOT: missing requirement 
[neo4j-server/1.0.0.SNAPSHOT] osgi.identity; 
osgi.identity=no.priv.bang.neo4j.karaf; type=osgi.bundle; 
version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]"; resolution:=mandatory [caused by: 
Unable to resolve no.priv.bang.neo4j.karaf/1.0.0.SNAPSHOT: missing requirement 
[no.priv.bang.neo4j.karaf/1.0.0.SNAPSHOT] osgi.service; 
filter:="(objectClass=org.apache.karaf.system.management.SystemMBean)"; 
effective:=active]]
        at 
org.apache.felix.resolver.ResolutionError.toException(ResolutionError.java:42) 
~[?:?]
        at 
org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:391) ~[?:?]
        at 
org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:377) ~[?:?]
        at 
org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:349) ~[?:?]
        at 
org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:218)
 ~[?:?]
        at 
org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:291) 
~[?:?]
        at 
org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1248)
 ~[?:?]
        at 
org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$1(FeaturesServiceImpl.java:1147)
 ~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
[?:?]
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
[?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]


Does anyone know what I might be missing?

What I have done, is:
 1. Add org.apache.karaf.system.core as a provided dependency
        <dependency>
            <groupId>org.apache.karaf.system</groupId>
            <artifactId>org.apache.karaf.system.core</artifactId>
            <version>${karaf.version}</version>
            <scope>provided</scope>
        </dependency>
 2. Add a @Reference for the SystemMBean to the DS component

As a shot in the dark, I have also tried adding a
<feature>system</feature> dependency to the template feature.xml of my
feature (it shouldn't be necessary, but it was woth a try).

As far as I can tell, the "system" bundle is alive and loaded, and
exposes the service I'm trying to inject:
 karaf@root()> bundle:list -t 1 org.apache.karaf.system.core
 START LEVEL 100 , List Threshold: 1
 ID │ State  │ Lvl │ Version │ Name
 ───┼────────┼─────┼─────────┼────────────────────────────────
 46 │ Active │  30 │ 4.1.5   │ Apache Karaf :: System :: Core
 karaf@root()> bundle:capabilities org.apache.karaf.system.core
 org.apache.karaf.system.core [46] provides:
 -------------------------------------------
 osgi.wiring.bundle; org.apache.karaf.system.core 4.1.5 [UNUSED]
 osgi.wiring.host; org.apache.karaf.system.core 4.1.5 [UNUSED]
 osgi.identity; org.apache.karaf.system.core 4.1.5 [UNUSED]
 osgi.wiring.package; org.apache.karaf.system 4.1.5 [UNUSED]
 osgi.wiring.package; org.apache.karaf.system.management 4.1.5 [UNUSED]
 service; [org.apache.karaf.system.SystemService] with properties:
    service.bundleid = 46
    service.id = 72
    service.scope = singleton
    Used by:
       org.apache.karaf.system.core [46]
 service; [org.apache.karaf.system.management.SystemMBean, 
javax.management.DynamicMBean, javax.management.MBeanRegistration] with 
properties:
    jmx.objectname = org.apache.karaf:type=system,name=root
    service.bundleid = 46
    service.id = 73
    service.scope = singleton
    Used by:
       org.apache.aries.jmx.whiteboard [18]
 karaf@root()>

The org.apache.karaf.system.core bundle exports the
org.apache.karaf.system.management package:
 Export-Package: org.apache.karaf.system;version="4.1.5",org.apache.kar
  af.system.management;uses:="javax.management";version="4.1.5"

My bundle imports the org.apache.karaf.system.management package:
 Import-Package: org.apache.karaf.system.management;version="[4.1,5)",o
  rg.neo4j.graphdb,org.neo4j.graphdb.event,org.neo4j.graphdb.factory,or
  ...

Is there anything else I should check?

Thanks!

Reply via email to