2014-01-30 32 views
2

我有一個JBoss Fuse 6.0.0。服務器,我想部署包含在jar中的OSGI包。在部署服務器日誌包含以下異常:R3進口不能包含指令

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: 

的谷歌搜索結果對於錯誤消息沒有太大的幫助。有人能幫助澄清或解決這個問題嗎?

回答

3

你的清單文件丟失的條目:

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

沒有這些假設你的包遵守與OSGi R3規範,所以resolution:="optional"無效。如果您添加這些清單條目,該捆綁包將被視爲符合R4並應該工作。

+0

謝謝,這解決了這個問題! – zovits