【问题标题】:Virgo server plugin resolver conflictVirgo 服务器插件解析器冲突
【发布时间】:2018-03-07 02:21:09
【问题描述】:

我有两个bundle,A导出两个包,然后B使用这两个包(org.dom4j , org.dom4j.io),B仍然使用其他bundle导出的spring包。如果我在 osgi 控制台中加载包 A 然后加载包 B,则没有解析器问题。

但是,如果我把这两个包放在一个 par 中,如果在 synthetic.context 包中会失败,说“使用违规:

A 的清单:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: device-openapi
Bundle-SymbolicName: device-openapi
Bundle-Version: 1.0.0
Export-Package: com.google.gson,
 com.google.gson.annotations,
 com.google.gson.internal,
 com.google.gson.internal.bind,
 com.google.gson.reflect,
 com.google.gson.stream,
 org.apache.commons.codec,
 org.apache.commons.codec.binary,
 org.apache.commons.codec.digest,
 org.apache.commons.codec.language,
 org.apache.commons.codec.language.bm,
 org.apache.commons.codec.net,
 org.apache.commons.io,
 org.apache.commons.io.comparator,
 org.apache.commons.io.filefilter,
 org.apache.commons.io.input,
 org.apache.commons.io.monitor,
 org.apache.commons.io.output,
 org.apache.commons.lang3,
 org.apache.commons.lang3.builder,
 org.apache.commons.lang3.concurrent,
 org.apache.commons.lang3.event,
 org.apache.commons.lang3.exception,
 org.apache.commons.lang3.math,
 org.apache.commons.lang3.mutable,
 org.apache.commons.lang3.reflect,
 org.apache.commons.lang3.text,
 org.apache.commons.lang3.text.translate,
 org.apache.commons.lang3.time,
 org.apache.commons.lang3.tuple,
 org.apache.commons.logging,
 org.apache.commons.logging.impl,
 org.apache.http,
 org.apache.http.annotation,
 org.apache.http.auth,
 org.apache.http.auth.params,
 org.apache.http.client,
 org.apache.http.client.config,
 org.apache.http.client.entity,
 org.apache.http.client.methods,
 org.apache.http.client.params,
 org.apache.http.client.protocol,
 org.apache.http.client.utils,
 org.apache.http.concurrent,
 org.apache.http.config,
 org.apache.http.conn,
 org.apache.http.conn.params,
 org.apache.http.conn.routing,
 org.apache.http.conn.scheme,
 org.apache.http.conn.socket,
 org.apache.http.conn.ssl,
 org.apache.http.conn.util,
 org.apache.http.cookie,
 org.apache.http.cookie.params,
 org.apache.http.entity,
 org.apache.http.entity.mime,
 org.apache.http.entity.mime.content,
 org.apache.http.impl,
 org.apache.http.impl.auth,
 org.apache.http.impl.client,
 org.apache.http.impl.conn,
 org.apache.http.impl.conn.tsccm,
 org.apache.http.impl.cookie,
 org.apache.http.impl.entity,
 org.apache.http.impl.execchain,
 org.apache.http.impl.io,
 org.apache.http.impl.pool,
 org.apache.http.io,
 org.apache.http.message,
 org.apache.http.params,
 org.apache.http.pool,
 org.apache.http.protocol,
 org.apache.http.util,
 org.apache.log4j,
 org.apache.log4j.chainsaw,
 org.apache.log4j.config,
 org.apache.log4j.helpers,
 org.apache.log4j.jdbc,
 org.apache.log4j.jmx,
 org.apache.log4j.lf5,
 org.apache.log4j.lf5.util,
 org.apache.log4j.lf5.viewer,
 org.apache.log4j.lf5.viewer.categoryexplorer,
 org.apache.log4j.lf5.viewer.configure,
 org.apache.log4j.net,
 org.apache.log4j.nt,
 org.apache.log4j.or,
 org.apache.log4j.or.jms,
 org.apache.log4j.or.sax,
 org.apache.log4j.pattern,
 org.apache.log4j.rewrite,
 org.apache.log4j.spi,
 org.apache.log4j.varia,
 org.apache.log4j.xml,
 org.dom4j,
 org.dom4j.bean,
 org.dom4j.datatype,
 org.dom4j.dom,
 org.dom4j.dtd,
 org.dom4j.io,
 org.dom4j.jaxb,
 org.dom4j.rule,
 org.dom4j.rule.pattern,
 org.dom4j.swing,
 org.dom4j.tree,
 org.dom4j.util,
 org.dom4j.xpath,
 org.dom4j.xpp,
 org.json,
 org.wcc.crypt,
 org.wcc.framework
Import-Package: javax.crypto,javax.crypto.spec,javax.naming,javax.nami
 ng.directory,javax.naming.event,javax.naming.ldap,javax.naming.spi,ja
 vax.net,javax.net.ssl,javax.security.auth.x500

B 的清单:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: NGCPlugin-service
Bundle-SymbolicName: com.myplugin.esdk.storage.service
Bundle-Version: 1.5.50
Bundle-Vendor: myplugin
Bundle-ClassPath: .
Tool: Bundlor 1.1.0.RELEASE
Export-Package: com.myplugin.esdk.storage.mvc,
 com.myplugin.esdk.storage.service.datastore,
 com.myplugin.esdk.storage.service.device,
 com.myplugin.esdk.storage.service.host,
 com.myplugin.esdk.storage.service.mount,
 com.myplugin.esdk.storage.service.resource,
 com.myplugin.esdk.storage.service.snapshot,
 com.myplugin.esdk.storage.service.vm
Import-Package: org.apache.commons.logging,
 org.dom4j,
 org.dom4j.io,
 org.json,org.w3c.dom,
 org.xml.sax,
 org.apache.commons.codec,
 org.apache.commons.codec.binary,
 org.apache.commons.codec.digest,
 org.apache.commons.codec.language,
 org.apache.commons.codec.language.bm,
 org.apache.commons.codec.net,
 org.apache.commons.io,
 org.slf4j,
 org.springframework.beans.factory.annotation

错误日志:

Resolver report:
        Uses violation: <Import-Package: org.springframework.beans.factory.annotation; version="0.0.0"> in bundle <com.myplugin.esdk.storage.ngc-2.1.7-com.myplugin.esdk.storage.service_1.5.50[1520387337960]>
             Resolver reported uses conflict for import
        An Import-Package could not be resolved. Resolver error data <Import-Package: com.myplugin.esdk.storage.service.snapshot; version="0.0.0">. Caused by missing constraint in bundle <com.myplugin.esdk.storage.ngc-2.1.7-synthetic.context_2.1.7>
             constraint: <Import-Package: com.myplugin.esdk.storage.service.snapshot; version="0.0.0"> constrained to bundle <com.myplugin.esdk.storage.ngc-2.1.7-com.myplugin.esdk.storage.service> constrained bundle version range "[1.5.50,1.5.50]"
            with attributes {module_scope=com.myplugin.esdk.storage.ngc-2.1.7}

有人知道如何解决这个问题吗?我尝试制作一个虚拟包,它使用 Import-Bundle 导入两个包的所有导出包,在我手动加载 A 和 B 包后,这些不是解析器错误......

【问题讨论】:

    标签: osgi osgi-bundle eclipse-virgo


    【解决方案1】:

    我不熟悉 PAR 文件的部署,使用 Virgo 时我通常会部署 PLAN 文件。这就是说,我怀疑问题可能是由于 A 导出了许多包 org.apache* ,这些包可能已经由 Virgo 中包含的其他包导出,并且是 Spring 的依赖项。因此,当您的 PAR 得到解决时,计划 B 发现自己处于从 A 以及通过传递依赖关系从 Spring 继承相同包的情况。

    我会尝试从 A manifest 中删除 Virgo 已经提供的所有包的导出。

    【讨论】:

    • 是的,我发现,它是 commons.logging,它正在被 spring 使用,我认为,在部署 par 之前,spring 应该已经被解析并使用其他包导出的 commons.logging ,那么当合成bundle试图解析bundle A和bundle B时,会发现,B使用的是spring,而spring使用的是原来的commons.logging,所以这个commons.logging在它的作用域内,然后A导出了commons.logging,所以在同一个范围内会有两个commons.logging,我想应该是这个导致了这个冲突。
    • 在一个一个加载的时候,B bundle可以加载spring,使用spring使用的commons.logging,所以,去吧。
    • Virgo 中还包含许多额外的 org.apache.* 包,HTTP 客户端就是其中之一。您不应该重新导出它们,或者至少确保从 A 导出正确版本并从 B 导入正确版本,否则系统会找到两个候选者,将随机选择一个,结果将无法预测。
    猜你喜欢
    • 1970-01-01
    • 2020-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多