R3导入不能包含指令

时间:2014-01-30 13:13:56

标签: java osgi fuseesb

我有一个JBoss Fuse 6.0.0。服务器,我想部署一个包含在jar中的OSGI包。部署后,服务器日志包含以下异常:

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

捆绑清单不包含任何我认为是指令的东西(虽然我可能会弄错):

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: 

Google错误消息的结果对此没有多大帮助。有人可以帮助澄清或解决这个问题吗?

1 个答案:

答案 0 :(得分:3)

您的清单文件缺少条目:

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

如果没有那些假设您的捆绑包符合OSGi R3规范,那么resolution:="optional"无效。如果您添加这些清单条目,该捆绑包将被视为符合R4并且应该有效。