I have a attached a small Maven-based project that shows the current package resolution problem in OSGi environments.
Execute "mvn --fail-at-end clean install" on the root project and have a look at the log output. You get the following:
[INFO] --- karaf-maven-plugin:4.0.5:verify (verify) @ com.rabbitmq.issue164.assembly.karaf ---
[INFO] Using repositories:
http://uk.maven.org/maven2@id=UK[INFO] Verification of feature com.rabbitmq/3.6.3 succeeded
[WARNING] Feature resolution failed for [com.rabbitmq/3.6.4]
Message:
Unable to resolve root: missing requirement [root] osgi.identity;
osgi.identity=com.rabbitmq; type=karaf.feature; version=3.6.4;
filter:="(&(osgi.identity=com.rabbitmq)(ty
pe=karaf.feature)(version>=3.6.4))"
[caused by: Unable to resolve com.rabbitmq/3.6.4: missing requirement
[com.rabbitmq/3.6.4] osgi.identity; osgi.identity=com.rabbitmq.client;
typ
e=osgi.bundle; version="[3.6.4,3.6.4]"; resolution:=mandatory
[caused by: Unable to resolve com.rabbitmq.client/3.6.4: missing
requirement [com.rabbitmq.client/3.6.4] osgi.wiring.p
ackage; filter:="(osgi.wiring.package=junit.framework)"]]
Repositories: {
file:C:\Users\cfiehe\Desktop\rabbitmq-java-client_issue-164\assembly\karaf\target/karaf/features.xml
mvn:org.apache.karaf.features/framework/4.0.5/xml/features
mvn:org.apache.karaf.features/standard/4.0.5/xml/features
mvn:org.ops4j.pax.web/pax-web-features/4.2.6/xml/features
}
Resources: {
mvn:com.rabbitmq/amqp-client/3.6.4
mvn:org.apache.felix/org.apache.felix.configadmin/1.8.8
mvn:org.apache.felix/org.apache.felix.fileinstall/3.5.4
mvn:org.apache.karaf.features/org.apache.karaf.features.core/4.0.5
mvn:org.apache.sshd/sshd-core/0.14.0
mvn:org.ops4j.pax.logging/pax-logging-api/1.8.5
mvn:org.ops4j.pax.logging/pax-logging-service/1.8.5
mvn:org.ops4j.pax.url/pax-url-aether/2.4.7
}
I
have declared two Karaf features, one using version 3.6.3, the other
using 3.6.4 of amqp-client. During the verification phase, the Karaf
plugin checks if all package imports can be fulfilled. The first feature
based on version 3.6.3 can be resolved. The second one fails, because
the JUnit packages are declared as mandatory requirements and are not
provided by any bundle.
Navigate to
"rabbitmq-java-client_issue-164/platform/pax-runner" and execute "mvn
pax:run". Now, you get a basic Felix OSGi framework 5.4.0, equipped with
the amqp-client bundle in version 3.6.3 and 3.6.4. During framework
start, you get the following error:
ERROR: Bundle com.rabbitmq.client
[5] Error starting file:bundles/com.rabbitmq.client_3.6.4.jar
(org.osgi.framework.BundleException: Unable to resolve
com.rabbitmq.client [5](R 5.0
): missing requirement
[com.rabbitmq.client [5](R 5.0)] osgi.wiring.package;
(osgi.wiring.package=junit.framework) Unresolved requirements:
[[com.rabbitmq.client [5](R 5.0)] osgi.w
iring.package; (osgi.wiring.package=junit.framework)])
org.osgi.framework.BundleException:
Unable to resolve com.rabbitmq.client [5](R 5.0): missing requirement
[com.rabbitmq.client [5](R 5.0)] osgi.wiring.package;
(osgi.wiring.package
=junit.framework) Unresolved requirements:
[[com.rabbitmq.client [5](R 5.0)] osgi.wiring.package;
(osgi.wiring.package=junit.framework)]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4111)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2117)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
at java.lang.Thread.run(Thread.java:745)
Execute "bundles" on the shell to verify the bundle states:
g! bundles
0|Active | 0|org.apache.felix.framework (5.4.0)
1|Active | 1|org.apache.felix.gogo.command (0.16.0)
2|Active | 1|org.apache.felix.gogo.runtime (0.16.2)
3|Active | 1|org.apache.felix.gogo.shell (0.12.0)
4|Active | 5|com.rabbitmq.client (3.6.3)
5|Installed | 5|com.rabbitmq.client (3.6.4)
The
bundle "com.rabbitmq.client (3.6.3)" is active which means that all
mandatory package import requirements are satisfied, whereas bundle
"com.rabbitmq.client (3.6.4)" keeps in the installed state, because the
JUnit package dependencies cannot be fulfilled.