javaosgiapache-felixgogo-shell

How to see why bundle requirements are not fulfilled in Apache Felix Log?


I'm using Felix in embedded mode, with the File Install bundle, and have a bundle that is Installed but not Resolved (thus not Starting / Active), and I'm struggling more than I thought one would have to finding the root cause in the log...

How / where do you get those helpful looking "Unable to resolve ... because..." or "BundleException: Unresolved constraint in bundle ... Unable to resolve ... missing requirement ... osgi.wiring.package" kind of messages in the log, automatically from Felix framework and/or the File Install bundle? I'm not seeing anything like that - should I be? Where?

I've also added logging (via Apache Felix Log and osgi-loglistener-slf4j), but still nada - do you need to do more than I did for enabling logging for this kind of problem in (Embedded) Felix?

I've then added the Felix Gogo Shell CLI, and found that its inspect command, isn't very helpful either (does not work for bundles that are not resolved), and only start will show the root cause - but how can I get this to get logged, without having to have a console and do a start:

g! lb  
START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (5.6.1)|5.6.1
    1|Active     |    1|Apache Felix File Install (3.5.4)|3.5.4
    2|Active     |    1|Apache Felix Remote Shell (1.1.2)|1.1.2
    3|Active     |    1|Apache Felix Gogo Runtime (0.16.2)|0.16.2
    4|Active     |    1|Apache Felix Gogo Command (0.16.0)|0.16.0
    5|Active     |    1|Apache Felix Gogo Shell (0.12.0)|0.12.0
    6|Installed  |    1|osgi.testplugin (1.0.0.SNAPSHOT)|1.0.0.SNAPSHOT
g! inspect req * 6
Bundle 6 is not resolved.
g! start 6
org.osgi.framework.BundleException: Unable to resolve ch.vorburger.minecraft.osgi.testplugin [8](R 8.0): missing requirement [ch.vorburger.minecraft.osgi.testplugin [8](R 8.0)] osgi.wiring.package; (osgi.wiring.package=org.spongepowered.api.command) Unresolved requirements: [[ch.vorburger.minecraft.osgi.testplugin [8](R 8.0)] osgi.wiring.package; (osgi.wiring.package=org.spongepowered.api.command)]

I do understand that due to OSGi's async bundle initialization, it may not be obvious when to log a failed bundle start, as it may have to wait for dependent bundles to come up? Couldn't it still.. log this kind of error, after some sort of grace period?


Solution

  • I had a similar problem in tests before I found the pax exam option to check that all bundles are resolved.

    What I did was to programmatically go through the list of bundles and call start on each bundle that is not started. bundle.start() then throws an exception with the reason like the console command above.

    Not sure if felix can be set to also log this by default.