Question

I have a JBoss Fuse 6.0.0. server where I'd like to deploy an OSGI bundle contained in a jar. Upon deployment the server logs contain the following exception:

13:54:01,802 | INFO  | l Console Thread | Console                          | 15 - org.apache.karaf.shell.console - 2.3.0.redhat-60024 | Exception caught while executing command
org.apache.karaf.shell.console.MultiException: Error installing bundles:
    Unable to install bundle file:/tmp/my-war-1.0.0-SNAPSHOT.jar
    at org.apache.karaf.shell.console.MultiException.throwIf(MultiException.java:91)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
    at org.apache.karaf.shell.osgi.InstallBundle.doExecute(InstallBundle.java:70)[47:org.apache.karaf.shell.osgi:2.3.0.redhat-60024]
    at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
    at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
    at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
    at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:474)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
    at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:400)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
    at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
    at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
    at org.apache.karaf.shell.console.jline.Console.run(Console.java:176)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
    at org.apache.karaf.shell.console.jline.DelayedStarted.run(DelayedStarted.java:61)[15:org.apache.karaf.shell.console:2.3.0.redhat-60024]
Caused by: java.lang.Exception: Unable to install bundle file:/tmp/my-war-1.0.0-SNAPSHOT.jar
    at org.apache.karaf.shell.osgi.InstallBundle.doExecute(InstallBundle.java:45)[47:org.apache.karaf.shell.osgi:2.3.0.redhat-60024]
    ... 11 more
Caused by: org.osgi.framework.BundleException: R3 imports cannot contain directives.
    at org.apache.felix.framework.util.manifestparser.ManifestParser.normalizeImportClauses(ManifestParser.java:351)[org.apache.felix.framework-4.0.3.redhat-60024.jar:]
    at org.apache.felix.framework.util.manifestparser.ManifestParser.<init>(ManifestParser.java:163)[org.apache.felix.framework-4.0.3.redhat-60024.jar:]
    at org.apache.felix.framework.BundleRevisionImpl.<init>(BundleRevisionImpl.java:119)[org.apache.felix.framework-4.0.3.redhat-60024.jar:]
    at org.apache.felix.framework.BundleImpl.createRevision(BundleImpl.java:1199)[org.apache.felix.framework-4.0.3.redhat-60024.jar:]
    at org.apache.felix.framework.BundleImpl.<init>(BundleImpl.java:96)[org.apache.felix.framework-4.0.3.redhat-60024.jar:]
    at org.apache.felix.framework.Felix.installBundle(Felix.java:3080)[org.apache.felix.framework-4.0.3.redhat-60024.jar:]
    at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:165)[org.apache.felix.framework-4.0.3.redhat-60024.jar:]
    at org.apache.karaf.shell.osgi.InstallBundle.doExecute(InstallBundle.java:43)[47:org.apache.karaf.shell.osgi:2.3.0.redhat-60024]
    ... 11 more

The bundle manifest does not contain anything that I'd consider as a directive (though I might be mistaken):

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: root
Build-Jdk: 1.7.0_25
FAB-Provided-Dependency: org.apache.cxf:*
                            org.apache.camel:* 
                            [...SNIP...]
                            org.quartz:*
FAB-Version-Range-Digits: 0
Import-Package: bsh;resolution:="optional",
                                edu.emory.mathcs.backport.java.util.concurrent;resolution:="optional",
                            [...SNIP...]
                            org.bouncycastle.util;resolution:="optional",                               
                            *
ProjectVersion: 1.0.0-SNAPSHOT
SVNRevisionNumber: 

The Google results for the error message did not help that much. Could someone please help with clarifying or resolving this problem?

Was it helpful?

Solution

Your manifest file is missing the entries:

Bundle-ManifestVersion: 2
Bundle-SymbolicName: .....

Without those your bundle is assumed to comply with the OSGi R3 specification, so resolution:="optional" is not valid. If you add those manifest entries the bundle will be treated as R4 compliant and should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top