We need FindBugs JSR305 as a dependency and we deploy it as a wrapped OSGi bundle to Fuse 6.3.0. At first it looks like everything is fine and the components are working well. But after a restart, many bundles that depend on javax.annoation API are not starting anymore. We found out, that the javax.annoation API Bundle that comes with the Fuse installation does not export the package javax.annoation after the restart. Although the bundle of the javax.annotation API starts without errors and exports other packages.
The error occurs with RedHat Fuse 6.3.0.475 and the corresponding Karaf 2.4.0.redhat-630475.
We already tried the ServiceMix JSR305 Bundle from Maven Repository, but it exports the javax.annotation in version 1.1.0 and we need version 3.0.2. Maybe this is a mistake too, because I would expect an export of javax.annotation 3.0.2 from the bundle version 3.0.2_1.
Manifest-Version: 1.0
Bnd-LastModified: 1493877706145
Build-Jdk: 1.8.0_111
Built-By: jbonofre
Bundle-Description: This OSGi bundle wraps jsr305 1.1.0 jar file.
Bundle-DocURL: http://www.apache.org/
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion: 2
Bundle-Name: Apache ServiceMix :: Bundles :: jsr305
Bundle-SymbolicName: org.apache.servicemix.bundles.jsr305
Bundle-Vendor: The Apache Software Foundation
Bundle-Version: 3.0.2.1
Created-By: Apache Maven Bundle Plugin
Export-Package: javax.annotation;version="1.1.0";uses:="javax.annotation.meta",javax.annotation.concurrent;version="1.1.0",javax.annotation.meta;version="1.1.0";uses:="javax.annotation"
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.5))"
Tool: Bnd-3.2.0.201605172007
Reproduction
Setup a new Fuse 6.3.0 installation. With "pacakges:exports | grep javax.annoation;" you can find out that javax.annoation is exported in version 1.0.0 from System Bundle and in version 1.2.0 from javax.annoation API.
JBossFuse:karaf@root> packages:exports | grep javax.annotation\;
0 javax.annotation; version=1.0.0
60 javax.annotation; version=1.2.0
Now install FindBugs JSR305 as a wrapped OSGi bundle to the instance. There are three exports of the javax.annotation package now including version 3.0.2 of the FindBugs JSR305 bundle and everything is working.
JBossFuse:karaf@root> packages:exports | grep javax.annotation\;
0 javax.annotation; version=1.0.0
60 javax.annotation; version=1.2.0
294 javax.annotation; version=3.0.2
Now restart the instance via admin script or "dev:restart" and after the instance is up again you will see some broken bundles, because javax.annoation API stopped to export version 1.2.0 of the javax.annotation package.
JBossFuse:karaf@root> packages:exports | grep javax.annotation\;
0 javax.annotation; version=1.0.0
294 javax.annotation; version=3.0.2
If you try the same with a fresh Fuse 7.0.0 installation, which runs with Karaf 4.2.0 and where javax.annotation API is still included, the error will not occur. It also works with Fuse 7.7.0, but there javax.annotation API is not included anymore and the java.annotation packages are exported just from Sytem Bundle.