Skip to main content

Wrap deployer

The wrap deployer allows you to hot deploy non-OSGi jar files ("classical" jar files) from the deploy folder. It's a standard deployer (you don't need to install additional Karaf features):

karaf@trun()> la|grep -i wrap
 35 | Active   |  24 | 4.0.0.SNAPSHOT        | Apache Karaf :: Deployer :: Wrap Non OSGi Jar
 92 | Active   |   5 | 2.4.1                 | OPS4J Pax Url - wrap:

Karaf wrap deployer looks for jar files in the deploy folder. The jar files is considered as non-OSGi if the MANIFEST doesn't contain the Bundle-SymbolicName and Bundle-Version attributes, or if there is no MANIFEST at all. The non-OSGi jar file is transformed into an OSGi bundle. The deployer tries to populate the Bundle-SymbolicName and Bundle-Version extracted from the jar file path. For example, if you simply copy commons-lang-2.3.jar (which is not an OSGi bundle) into the deploy folder, you will see:

karaf@trun> la|grep -i commons-lang
[ 41] [Active ] [       ] [ 60] commons-lang (2.3)

If you take a look on the commons-lang headers, you can see that the bundle exports all packages with optional resolution and that Bundle-SymbolicName and Bundle-Version have been populated:

karaf@trun> bundle:headers 41

commons-lang (41)
-----------------
Specification-Title = Commons Lang
Tool = Bnd-0.0.357
Specification-Version = 2.3
Specification-Vendor = Apache Software Foundation
Implementation-Version = 2.3
Generated-By-Ops4j-Pax-From = wrap:file:/home/onofreje/workspace/karaf/
    assembly/target/apache-karaf-2.99.99-SNAPSHOT/deploy/commons-lang-2.3
    .jar$ Bundle-SymbolicName=commons-lang&Bundle-Version=2.3
Implementation-Vendor-Id = org.apache
Created-By = 1.6.0_21 (Sun Microsystems Inc.)
Implementation-Title = Commons Lang
Manifest-Version = 1.0
Bnd-LastModified = 1297248243231
X-Compile-Target-JDK = 1.1
Originally-Created-By = 1.3.1_09-85 ("Apple Computer, Inc.")
Ant-Version = Apache Ant 1.6.5
Package = org.apache.commons.lang
X-Compile-Source-JDK = 1.3
Extension-Name = commons-lang
Implementation-Vendor = Apache Software Foundation

Bundle-Name = commons-lang
Bundle-SymbolicName = commons-lang
Bundle-Version = 2.3
Bundle-ManifestVersion = 2

Import-Package =
        org.apache.commons.lang;resolution:=optional,
        org.apache.commons.lang.builder;resolution:=optional,
        org.apache.commons.lang.enum;resolution:=optional,
        org.apache.commons.lang.enums;resolution:=optional,
        org.apache.commons.lang.exception;resolution:=optional,
        org.apache.commons.lang.math;resolution:=optional,
        org.apache.commons.lang.mutable;resolution:=optional,
        org.apache.commons.lang.text;resolution:=optional,
        org.apache.commons.lang.time;resolution:=optional
Export-Package =
        org.apache.commons.lang;uses:="org.apache.commons.lang.builder,
           org.apache.commons.lang.math,org.apache.commons.lang.exception",
        org.apache.commons.lang.builder;
             uses:="org.apache.commons.lang.math,org.apache.commons.lang",
        org.apache.commons.lang.enum;uses:=org.apache.commons.lang,
        org.apache.commons.lang.enums;uses:=org.apache.commons.lang,
        org.apache.commons.lang.exception;uses:=org.apache.commons.lang,
        org.apache.commons.lang.math;uses:=org.apache.commons.lang,
        org.apache.commons.lang.mutable;uses:="org.apache.commons.lang,
             org.apache.commons.lang.math",
        org.apache.commons.lang.text;uses:=org.apache.commons.lang,
        org.apache.commons.lang.time;uses:=org.apache.commons.lang

You may set the manifest headers by specifying them as URL parameters. The token '$' is used to separate the hierarchy path and query parts of the URL, with standard URL syntax for query parameters of key=value pairs joined by '&'. On the command line you must use single quotes around the URL to prevent the shell from attempting variable expansion, and if present, you must escape exclamation marks with a backslash.

install -s 'wrap:mvn:jboss/jbossall-client/4.2.3.GA/   \\
    $Bundle-SymbolicName=jbossall-client&Bundle-Version=4.2.3.GA&   \\
    Export-Package=org.jboss.remoting;version="4.2.3.GA",\!*'

If defined in a features.xml file, you'll need to escape any ampersands and quotes, or use a CDATA tag:

<bundle>wrap:mvn:jboss/jbossall-client/4.3.2.GA/   \\
    $Bundle-SymbolicName=jbossall-client   \\
    &Bundle-Version=4.3.2.GA   \\
    &Export-Package=org.jboss.remoting;version="4.3.2.GA",!*
</bundle>

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!