2 Replies Latest reply on Aug 21, 2010 12:11 AM by atum22

    OSGi versioning does not appear to be working

    atum22

      Hello.  I am using 4.3.0-fuse-SNAPSHOT, using the most recent version from trunk.

       

      I am experiencing an issue where my bundles are not using the bundles explicitly set in the import, but instead appear to be using the bundle with the highest version.

       

      To test this, I made a really simple project that uses the saxon v8.7.  The 4.3.0 servicemix comes with Saxon v9.1.0.8 out of the box.  Specifically, I have 'net.sf.saxon.*;version="8.7";' in the 'Import-Package' instruction for the maven-bundle-plugin.

       

      When I install my project that uses saxon v8.7, on a vanilla 4.3.0 of Servicemix, it does not complain about not finding the correct version of saxon, it instead uses the v9.1.0.8 bundle, which is not what I want to happen.

       

      If I uninstall the v9.1.0.8 bundle, and perform an osgi:update on my bundle, it now complains that it cannot find v8.7 of saxon.  It appears as if it is turning my 'version="8.7";' into 'version>="8.7";'.

       

      I also looked over the headers of the v9.1.0.8 bundle, and they appear correct.  The export parameter in the manifest does contain ';version="9.1.0.8";.

       

      Am I doing something wrong?  This is causing me a lot of headaches since some of my bundles have to use very specific versions of other bundles.

       

      Attached is a throwaway project to help show what I am talking about.

       

      Thanks.

        • 1. Re: OSGi versioning does not appear to be working
          gertv

          L.S.,

           

          In OSGi, when a single version is specified on the import, that version number indicates the lower bound for a version range.  So, an import that says 'net.sf.saxon;version:=8.7' tells the framework find a matching package export with version 8.7 or higher.  The platform will then pick the highest version available to match that requirement.

           

          You can explicitly add an upper bound to your bundle's OSGi import to make sure your bundle imports the right version, e.g. 'net.sf.saxon;version:=[8.7,9)' would tell the framework to pick version 8.7 or higher, but lower than 9.

           

          Regards,

           

          Gert

          • 2. Re: OSGi versioning does not appear to be working
            atum22

            Hello Gert,

            Thank you so much, adding the range identifiers is exactly what I was looking for.  I am so used to Maven and have very defined versions.

             

            I figured out how to change the version policy that the maven plugin sends to the bnd tool.  I added "<_versionpolicy>[${version;==;${@}},${version;==;${@}}]</_versionpolicy>" to the instructions for the plugin, and it now does what I want.

             

            Thanks again,

            Matt

             

            Edited by: doublematt on Aug 21, 2010 4:10 AM