2012-01-04 4 views
3

「maven-bundle-plugin」を使用してOSGiバンドルを作成しました( "jruby-complete-1.4.0.jar"をosgiバンドルとして、依存関係のみが "jruby-complete-1.4.0.jar"であることに注意してください)。diagコマンド(#diag XX)を使用してosgiコンソールからバンドルをチェックすると、いくつかのパッケージが見つからないというメッセージが表示されます。OSGiで「オプションでインポートされたパッケージが見つかりません」問題を解決するには

osgi> diag 51 
reference:file:dropins/jruby-complete-1.4.0.wso2v1.jar [51] 
    Direct constraints which are unresolved: 
    Missing optionally imported package com.sun.mirror.apt_0.0.0. 
    Missing optionally imported package com.sun.mirror.declaration_0.0.0. 
    Missing optionally imported package com.sun.mirror.type_0.0.0. 
    Missing optionally imported package com.sun.mirror.util_0.0.0. 
    Missing optionally imported package org.apache.bsf.util_0.0.0. 
    Missing optionally imported package org.jgrapht_0.0.0. 
    Missing optionally imported package org.jgrapht.graph_0.0.0. 
    Missing optionally imported package sun.misc_0.0.0. 

私のpomは、だから、

<plugin> 
       <groupId>org.apache.felix</groupId> 
       <artifactId>maven-bundle-plugin</artifactId> 

       <extensions>true</extensions> 
       <configuration> 
        <instructions> 
         <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
         <Bundle-Name>${project.artifactId}</Bundle-Name> 
         <Export-Package> 
          com.kenai.*, 
          com.sun.jna.*, 
          org.jruby.*, 
          org.joni.*,        
         </Export-Package> 
         <Import-Package>     
         *;resolution:=optional 
         </Import-Package> 
         <Fragment-Host>bsf-all</Fragment-Host> 
      <DynamicImport-Package>*</DynamicImport-Package>  
      <Embed-Dependency>*;scope=compile|runtime;inline=true;</Embed-Dependency>  
        </instructions> 
       </configuration> 
      </plugin> 

、私は[2] ポンポンのように<Import-Package>オプションでそれらの「オプションの不足しているパッケージ」を追加しようとしたが、それはのような多くの問題を提供します。

ference:file:dropins/jruby-complete-1.4.0.wso2v1.jar [51] 
Constraints from the fragment conflict with the host: Import-Package: *; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.apt; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.declaration; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.type; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: com.sun.mirror.util; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: javax.management; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: javax.script; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: javax.swing.plaf.basic; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: org.apache.bsf; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: org.apache.bsf.util; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: org.jgrapht; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: org.jgrapht.graph; version="0.0.0" 
Constraints from the fragment conflict with the host: Import-Package: org.jruby.anno; version="[1.4.0,2.0.0)" 
Constraints from the fragment conflict with the host: Import-Package: org.jruby.exceptions; version="[1.4.0,2.0.0)" 
Constraints from the fragment conflict with the host: Import-Package: org.jruby.runtime; version="[1.4.0,2.0.0)" 
Constraints from the fragment conflict with the host: Import-Package: org.jruby.runtime.builtin; version="[1.4.0,2.0.0)" 
Constraints from the fragment conflict with the host: Import-Package: sun.misc; version="0.0.0" 
Direct constraints which are unresolved: 
    Missing imported package com.sun.mirror.apt_0.0.0. 
    Missing imported package com.sun.mirror.declaration_0.0.0. 
    Missing imported package com.sun.mirror.type_0.0.0. 
    Missing imported package com.sun.mirror.util_0.0.0. 
    Missing imported package org.apache.bsf.util_0.0.0. 
    Missing imported package org.jgrapht_0.0.0. 
    Missing imported package org.jgrapht.graph_0.0.0. 
    Missing optionally imported package org.jruby.anno_[1.4.0,2.0.0). 
    Missing optionally imported package org.jruby.exceptions_[1.4.0,2.0.0). 
    Missing optionally imported package org.jruby.runtime_[1.4.0,2.0.0). 
    Missing optionally imported package org.jruby.runtime.builtin_[1.4.0,2.0.0). 
    Missing imported package sun.misc_0.0.0. 

pom.xml [2];

<plugin> 
       <groupId>org.apache.felix</groupId> 
       <artifactId>maven-bundle-plugin</artifactId> 

       <extensions>true</extensions> 
       <configuration> 
        <instructions> 
         <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
         <Bundle-Name>${project.artifactId}</Bundle-Name> 
         <Export-Package> 
          com.kenai.*, 
          com.sun.jna.*, 
          org.jruby.*, 
          org.joni.*,        
         </Export-Package> 
         <Import-Package>     
         com.sun.mirror.apt.*, 
         com.sun.mirror.declaration.*, 
         com.sun.mirror.type.*, 
         com.sun.mirror.util.*, 
         org.apache.bsf.util.*, 
         org.jgrapht.*, 
         org.jgrapht.graph.*, 
         sun.misc.*, 
          *;resolution:=optional 
         </Import-Package> 
         <Fragment-Host>bsf-all</Fragment-Host> 
      <DynamicImport-Package>*</DynamicImport-Package>  
      <Embed-Dependency>*;scope=compile|runtime;inline=true;</Embed-Dependency>  
        </instructions> 
       </configuration> 
      </plugin> 

上記の問題をどのように解決できますか? 私は他のバンドルに必要ないくつかのパッケージをエクスポートしています...私はここで何か間違っていますか?

答えて

6

これらのパッケージは(任意)ですので、必ずしも問題はありません。

これらの依存関係は、あなたのバンドルにバイトコードを検査することで、バンドルプラグインによって発見されました:ポスター改正質問後

UPDATE。通常は必須の依存関係になりますが、何らかの理由で<Import-Package>*;resolution:=optional</Import-Package>を追加してオプションにしました。なぜあなたはそれをしたのか分かりません...

パッケージを解決する正しい方法は、それらをエクスポートするバンドルを見つけることです。たとえば、バンドルにパッケージorg.jgraphtが必要です。したがって、そのパッケージをエクスポートするバンドルをインストールする必要があります。

1つの例外は、明らかにJREに由来していますが、一般的には使用されていないsun.miscパッケージです。 OSGiフレームワークは、デフォルトでは、このパッケージを利用可能にしていないが、あなたは以下の設定を追加することによって、それらを設定することができます。

org.osgi.framework.system.packages.extra=sun.misc 

この設定を配置する正確なファイルまたは場所があなたのOSGiフレームワークに依存 - あなたは指定していませんどちらを使用しているのかは分かりませんので、設定がどのように設定されているかのドキュメントを確認してください。

+0

私は[1]のようなエラーが発生したため、明示的に追加しました。だから、私はそれらの "オプションのパッケージがない問題"について心配する必要はないと言いますか? [1]未解決の直接制約: オプションでインポートされたパッケージcom.sun.mirror.apt_0.0.0が不足しています。 オプションでインポートされたパッケージcom.sun.mirror.declaration_0.0.0がありません。 オプションでインポートされたパッケージcom.sun.mirror.type_0.0.0がありません。 オプションでインポートされたパッケージcom.sun.mirror.util_0.0.0が欠落しています。 – Ratha

+0

@Rathaあなたが元々持っていたエラーメッセージ、つまり、 ''命令を追加する前にはっきりしていません。質問を明確にするために質問を言い換えてください。また、達成しようとしていることについていくつかの情報を追加すると便利です。たとえば、なぜJNA、Kenai、JRubyなどの全体を再パッケージ化してエクスポートしていますか? BSFの断片で?? –

+0

私は質問で直面している問題について少し明確にしました。もう一度チェックしてください。apache BSFプロジェクトの断片バンドルとしてホストしています。それは間違っていますか? – Ratha

関連する問題