Karaf
  1. Karaf
  2. KARAF-1585

Installing using wrap protocol fails when specifying bundle version

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.7
    • Fix Version/s: 2.2.9, 2.3.0, 3.0.0
    • Component/s: None
    • Labels:
      None

      Description

      I follow the docs at
      http://karaf.apache.org/manual/2.2.7/developers-guide/creating-bundles.html

      at the section Creating bundles for third party dependencies

      I try to execute as documented

      karaf@root> osgi:install wrap:mvn:commons-lang/commons-lang/2.4,Bundle-SymbolicName=commons-lang&Bundle-Version=2.4
      java.net.MalformedURLException: no protocol: Bundle-SymbolicName=commons-lang&Bundle-Version=2.4
      

      But it fails.

        Activity

        Hide
        Claus Ibsen added a comment -

        I think the doc is wrong, it should now be a semi colon instead

        karaf@root> osgi:install wrap:mvn:commons-lang/commons-lang/2.4;Bundle-SymbolicName=commons-lang&Bundle-Version=2.4
        Bundle ID: 78
        commons-lang&Bundle-Version=2.4
        

        Which then works

        Show
        Claus Ibsen added a comment - I think the doc is wrong, it should now be a semi colon instead karaf@root> osgi:install wrap:mvn:commons-lang/commons-lang/2.4;Bundle-SymbolicName=commons-lang&Bundle-Version=2.4 Bundle ID: 78 commons-lang&Bundle-Version=2.4 Which then works
        Hide
        Claus Ibsen added a comment -

        I am not sure if the comma was supported in a previous release and changed to semi colon now.

        Show
        Claus Ibsen added a comment - I am not sure if the comma was supported in a previous release and changed to semi colon now.
        Hide
        Claus Ibsen added a comment -

        Ah its a $ sign instead.

        No wonder ppl think this is hard.

        Show
        Claus Ibsen added a comment - Ah its a $ sign instead. No wonder ppl think this is hard.
        Hide
        Claus Ibsen added a comment -
        Show
        Claus Ibsen added a comment - Well dont work either with $. Instructions from here http://karaf.922171.n3.nabble.com/Arguments-to-wrap-protocol-in-a-feature-definition-td3807247.html
        Hide
        Claus Ibsen added a comment -

        We need this in Camel to support the camel-leveldb feature that needs to be installed as a wrap
        karaf@root> osgi:install wrap:mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2$Bundle-SymbolicName=Foo$Bundle-Version=1.2
        java.lang.RuntimeException: URL [mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2-SymbolicName=Foo-Version=1.2] could not be resolved.

        Show
        Claus Ibsen added a comment - We need this in Camel to support the camel-leveldb feature that needs to be installed as a wrap karaf@root> osgi:install wrap:mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2$Bundle-SymbolicName=Foo$Bundle-Version=1.2 java.lang.RuntimeException: URL [mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2-SymbolicName=Foo-Version=1.2] could not be resolved.
        Hide
        Guillaume Nodet added a comment -

        The $ sign is used for substitution in the shell, so you need to escape it, or to disable substitution using simple quotes:

        karaf@root>  osgi:install 'wrap:mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2$Bundle-SymbolicName=Foo&Bundle-Version=1.2'
        Bundle ID: 181
        karaf@root> headers 181
        
        Foo (181)
        ---------
        Archiver-Version = Plexus Archiver
        Specification-Title = leveldbjni-all
        Tool = Bnd-0.0.357
        Specification-Version = 1.2
        Specification-Vendor = FuseSource, Corp.
        Implementation-Version = 1.2
        Build-Jdk = 1.6.0_29
        Generated-By-Ops4j-Pax-From = wrap:mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2$Bundle-SymbolicName=Foo&Bundle-Version=1.2
        Implementation-Vendor-Id = org.fusesource.leveldbjni
        Created-By = 1.6.0_31 (Apple Inc.)
        Implementation-Title = leveldbjni-all
        Manifest-Version = 1.0
        Bnd-LastModified = 1340449217352
        Originally-Created-By = Apache Maven
        Built-By = chirino
        Implementation-Vendor = FuseSource, Corp.
        
        Bundle-Name = Foo
        Bundle-SymbolicName = Foo
        Bundle-Version = 1.2
        Bundle-ManifestVersion = 2
        
        Import-Package = 
        	org.fusesource.hawtjni.runtime;resolution:=optional,
        	org.fusesource.leveldbjni;resolution:=optional,
        	org.fusesource.leveldbjni.internal;resolution:=optional,
        	org.iq80.leveldb;resolution:=optional
        Export-Package = 
        	org.fusesource.hawtjni.runtime,
        	org.fusesource.leveldbjni;uses:="org.iq80.leveldb,org.fusesource.leveldbjni.internal,org.fusesource.hawtjni.runtime",
        	org.fusesource.leveldbjni.internal;uses:="org.iq80.leveldb,org.fusesource.hawtjni.runtime",
        	org.iq80.leveldb
        
        
        Show
        Guillaume Nodet added a comment - The $ sign is used for substitution in the shell, so you need to escape it, or to disable substitution using simple quotes: karaf@root> osgi:install 'wrap:mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2$Bundle-SymbolicName=Foo&Bundle-Version=1.2' Bundle ID: 181 karaf@root> headers 181 Foo (181) --------- Archiver-Version = Plexus Archiver Specification-Title = leveldbjni-all Tool = Bnd-0.0.357 Specification-Version = 1.2 Specification-Vendor = FuseSource, Corp. Implementation-Version = 1.2 Build-Jdk = 1.6.0_29 Generated-By-Ops4j-Pax-From = wrap:mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2$Bundle-SymbolicName=Foo&Bundle-Version=1.2 Implementation-Vendor-Id = org.fusesource.leveldbjni Created-By = 1.6.0_31 (Apple Inc.) Implementation-Title = leveldbjni-all Manifest-Version = 1.0 Bnd-LastModified = 1340449217352 Originally-Created-By = Apache Maven Built-By = chirino Implementation-Vendor = FuseSource, Corp. Bundle-Name = Foo Bundle-SymbolicName = Foo Bundle-Version = 1.2 Bundle-ManifestVersion = 2 Import-Package = org.fusesource.hawtjni.runtime;resolution:=optional, org.fusesource.leveldbjni;resolution:=optional, org.fusesource.leveldbjni.internal;resolution:=optional, org.iq80.leveldb;resolution:=optional Export-Package = org.fusesource.hawtjni.runtime, org.fusesource.leveldbjni;uses:= "org.iq80.leveldb,org.fusesource.leveldbjni.internal,org.fusesource.hawtjni.runtime" , org.fusesource.leveldbjni.internal;uses:= "org.iq80.leveldb,org.fusesource.hawtjni.runtime" , org.iq80.leveldb
        Hide
        Claus Ibsen added a comment - - edited

        Thanks from the shell the single quotes works. But from a features file its not possible.

        karaf@root> features:install camel-leveldb 
        Error executing command: no protocol: 'wrap:mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2$Bundle-Version=1.2'
        
        Show
        Claus Ibsen added a comment - - edited Thanks from the shell the single quotes works. But from a features file its not possible. karaf@root> features:install camel-leveldb Error executing command: no protocol: 'wrap:mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2$Bundle-Version=1.2'
        Hide
        Claus Ibsen added a comment -

        Also the export packages wont have Bundle-Version in the packages from the bundle itself. They dont carry version=1.2

        Bundle-Name = wrap_mvn_org.fusesource.leveldbjni_leveldbjni-all_1.2_Bundle-Version_1.2
        Bundle-SymbolicName = wrap_mvn_org.fusesource.leveldbjni_leveldbjni-all_1.2_Bundle-Version_1.2
        Bundle-Version = 1.2
        Bundle-ManifestVersion = 2

        Import-Package = 
        	org.fusesource.hawtjni.runtime;resolution:=optional,
        	org.fusesource.leveldbjni;resolution:=optional,
        	org.fusesource.leveldbjni.internal;resolution:=optional,
        	org.iq80.leveldb;resolution:=optional
        Export-Package = 
        	org.fusesource.hawtjni.runtime,
        	org.fusesource.leveldbjni;uses:="org.iq80.leveldb,org.fusesource.leveldbjni.internal,org.fusesource.hawtjni.runtime",
        	org.fusesource.leveldbjni.internal;uses:="org.iq80.leveldb,org.fusesource.hawtjni.runtime",
        	org.iq80.leveldb
        
        Show
        Claus Ibsen added a comment - Also the export packages wont have Bundle-Version in the packages from the bundle itself. They dont carry version=1.2 Bundle-Name = wrap_mvn_org.fusesource.leveldbjni_leveldbjni-all_1.2_Bundle-Version_1.2 Bundle-SymbolicName = wrap_mvn_org.fusesource.leveldbjni_leveldbjni-all_1.2_Bundle-Version_1.2 Bundle-Version = 1.2 Bundle-ManifestVersion = 2 Import-Package = org.fusesource.hawtjni.runtime;resolution:=optional, org.fusesource.leveldbjni;resolution:=optional, org.fusesource.leveldbjni.internal;resolution:=optional, org.iq80.leveldb;resolution:=optional Export-Package = org.fusesource.hawtjni.runtime, org.fusesource.leveldbjni;uses:= "org.iq80.leveldb,org.fusesource.leveldbjni.internal,org.fusesource.hawtjni.runtime" , org.fusesource.leveldbjni.internal;uses:= "org.iq80.leveldb,org.fusesource.hawtjni.runtime" , org.iq80.leveldb
        Hide
        Guillaume Nodet added a comment -

        You don't need to quote inside the feature definition. Only from the shell because the shell considers $ a reservers character.

        For the metadata, there's an overwrite property which you can use when re-bundling a bundle to define the behavior wrt to the existing metadata.
        For example:

        wrap:mvn:tomcat/commons-el/5.5.23$Import-Package=*;resolution:=optional&Export-Package=org.apache.commons.el*;-noimport:=true&overwrite=merge
        

        The default value is overwrite=keep which iirc keep the existing metadata intact, so only new headers can be added. Try with merge as shown in the example above.

        Show
        Guillaume Nodet added a comment - You don't need to quote inside the feature definition. Only from the shell because the shell considers $ a reservers character. For the metadata, there's an overwrite property which you can use when re-bundling a bundle to define the behavior wrt to the existing metadata. For example: wrap:mvn:tomcat/commons-el/5.5.23$Import-Package=*;resolution:=optional&Export-Package=org.apache.commons.el*;-noimport:= true &overwrite=merge The default value is overwrite=keep which iirc keep the existing metadata intact, so only new headers can be added. Try with merge as shown in the example above.
        Hide
        Claus Ibsen added a comment -

        I think there is an issue when using wrap in the features file. As the $ doesnt work, eg without the quotes. Only from the shell it works.

        Show
        Claus Ibsen added a comment - I think there is an issue when using wrap in the features file. As the $ doesnt work, eg without the quotes. Only from the shell it works.
        Hide
        Freeman Fang added a comment -

        Hi Claus,

        The wrap url in features should be like

        <bundle dependency='true'>wrap:mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2$Bundle-Version=1.2&Export-Package=*;-noimport:=true;version="1.2"</bundle>
        This way it can specify the export package version like

        Export-Package =
        org.fusesource.hawtjni.runtime;version=1.2,
        org.fusesource.leveldbjni;uses:="org.iq80.leveldb,org.fusesource.leveldbjni.internal,org.fusesource.hawtjni.runtime";version=1.2,
        org.fusesource.leveldbjni.internal;uses:="org.iq80.leveldb,org.fusesource.hawtjni.runtime";version=1.2,
        org.iq80.leveldb;version=1.2

        Freeman

        Show
        Freeman Fang added a comment - Hi Claus, The wrap url in features should be like <bundle dependency='true'>wrap:mvn:org.fusesource.leveldbjni/leveldbjni-all/1.2$Bundle-Version=1.2&Export-Package=*;-noimport:=true;version="1.2"</bundle> This way it can specify the export package version like Export-Package = org.fusesource.hawtjni.runtime;version=1.2, org.fusesource.leveldbjni;uses:="org.iq80.leveldb,org.fusesource.leveldbjni.internal,org.fusesource.hawtjni.runtime";version=1.2, org.fusesource.leveldbjni.internal;uses:="org.iq80.leveldb,org.fusesource.hawtjni.runtime";version=1.2, org.iq80.leveldb;version=1.2 Freeman
        Hide
        Freeman Fang added a comment -

        close it as "Not A Problem", feel free to reopen it if you have other concerns

        Show
        Freeman Fang added a comment - close it as "Not A Problem", feel free to reopen it if you have other concerns
        Hide
        Claus Ibsen added a comment -

        Can you guys update the documentation with

        • the link I provided had a non working example
        • you need to use quotes from the shell
        • there is no samples how to do this in a features file, which Freeman was the only one who could figure out how to do
        Show
        Claus Ibsen added a comment - Can you guys update the documentation with the link I provided had a non working example you need to use quotes from the shell there is no samples how to do this in a features file, which Freeman was the only one who could figure out how to do
        Hide
        Freeman Fang added a comment -

        the manual page need updated accordingly per the discussion here

        Show
        Freeman Fang added a comment - the manual page need updated accordingly per the discussion here
        Hide
        Freeman Fang added a comment -

        Hi Claus,

        Sure, the manual page need updated per the discussion here.
        Reopen this issue until I update the manual page.

        Freeman

        Show
        Freeman Fang added a comment - Hi Claus, Sure, the manual page need updated per the discussion here. Reopen this issue until I update the manual page. Freeman
        Hide
        Guillaume Nodet added a comment -

        Claus, the url remains the same in both the shell and xml, it's just those two environments do need different escaping. $ needs to be escaped in the shell and & in the xml. That's what we need to put in the manual I guess.

        Show
        Guillaume Nodet added a comment - Claus, the url remains the same in both the shell and xml, it's just those two environments do need different escaping. $ needs to be escaped in the shell and & in the xml. That's what we need to put in the manual I guess.
        Hide
        Claus Ibsen added a comment -

        Yes examples of all 3 uses cases in the manual would be very welcome.

        I know wrap is not an ideal solution. But many JARs are not OSGi compliant out of the box.
        And ppl need to be able to use them with Karaf anyway.

        So if we have a bit better docs and examples, then that would be great.

        Show
        Claus Ibsen added a comment - Yes examples of all 3 uses cases in the manual would be very welcome. I know wrap is not an ideal solution. But many JARs are not OSGi compliant out of the box. And ppl need to be able to use them with Karaf anyway. So if we have a bit better docs and examples, then that would be great.
        Show
        Freeman Fang added a comment - commit fix http://svn.apache.org/viewvc?rev=1355214&view=rev for trunk http://svn.apache.org/viewvc?rev=1355216&view=rev for 2.3.x branch http://svn.apache.org/viewvc?rev=1355212&view=rev for 2.2.x branch

          People

          • Assignee:
            Freeman Fang
            Reporter:
            Claus Ibsen
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development