簡體   English   中英

Felix:無法在JDK 9上添加擴展束

[英]Felix: unable to add extension bundle on JDK 9

遷移到JDK 9+后,我們圍繞apache Felix構建的OSGi容器開始無法安裝擴展包。 錯誤消息是:

Caused by: org.osgi.framework.BundleException: Could not create bundle object.
    at org.apache.felix.framework.Felix.installBundle(Felix.java:3095)
    ...
Caused by: java.lang.UnsupportedOperationException: Unable to add extension bundle.
    at org.apache.felix.framework.ExtensionManager.addExtensionBundle(ExtensionManager.java:439)
    at org.apache.felix.framework.Felix.installBundle(Felix.java:3061)
    ...

我們的Felix版本是5.6.10,這是當前的最新版本。 捆綁包清單的相關部分:

Created-By: Apache Maven Bundle Plugin
Fragment-Host: system.bundle; extension:=framework
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=9.0))"
Tool: Bnd-3.5.0.201709291849

調試顯示,用於安裝擴展的類加載器已移至JDK 9中的命名模塊。因此,必須為所有未命名模塊打開類加載器的程序包,以便從Felix框架中訪問它。

添加以下命令行選項后,它將起作用:

--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED

對於使用maven-surefire-plugin的單元測試,請使用:

 <configuration>
     <argLine>
         --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED
     </argLine>
 </configuration>

該解決方案似乎是從Felix的ExtensionManager記錄的,但未添加到異常消息中,因此在我自己的日志中找不到該消息:

        m_logger.log(bundle, Logger.LOG_WARNING,
            "Unable to add extension bundle - Maybe ClassLoader is not supported " +
                    "(on java9, try --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED)?");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM