当前位置: 首页 > 知识库问答 >
问题:

Blueprint-使用Pax Exam进行单元测试-无法解决依赖关系

周超英
2023-03-14

我们正在将基于spring的camel应用程序迁移到基于蓝图的camel应用程序。我们还将迁移到fuse 6.1版本。我正在使用带有Junit runner的Pax考试和apache felix容器来执行我的单元测试。我面临与ehcache manager相关的未解决捆绑包问题。我曾尝试将pax配置作为mavenBundle提供所需的依赖性,但没有任何运气。异常并没有给出缺少依赖项的细节,而是只给出了包的一般错误,即“osgi.willing.package=net.sf.ehcache”<我在pom中给出了必要的依赖性。xnl和eclipse没有显示任何错误。下面是Junit中使用的配置。

“@Configuration public Option[]config(){

    return options(systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
            systemProperty("Test.Property").value("system"),
            systemProperty("pax.exam.logging").value("none"),
            systemTimeout(600000),

            mavenBundle("commons-lang", "commons-lang", "2.5"),
            mavenBundle("commons-collections", "commons-collections", "3.2.1"),
            mavenBundle("commons-beanutils", "commons-beanutils", "1.8.3"),
            mavenBundle("commons-io", "commons-io", "2.0"),
            mavenBundle("ch.qos.logback", "logback-core", "1.0.9"),
            mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"),
            mavenBundle("org.slf4j", "slf4j-api", "1.7.5"),
            mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.5"),
            mavenBundle("net.sf.ehcache", "ehcache-core", "2.6.9"),
            mavenBundle("net.sf.ehcache", "ehcache", "1.5.0"),
            mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint", "1.1.0"),
            mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy", "1.0.0"),
            mavenBundle("org.apache.aries", "org.apache.aries.util", "1.1.0"),
            mavenBundle("channelservicelayer", "base", "1.0.0"),
            mavenBundle("asm", "asm-all", "3.1"),
            junitBundles()
            );
}'

我附上日志如下

---
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling SLF4J API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Jakarta Commons Logging API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Log4J API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling Avalon Logger API support.
org.ops4j.pax.logging.pax-logging-api[org.ops4j.pax.logging.internal.Activator] : Enabling JULI Logger API support.
16:58:10.097 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.ops4j.pax.logging.pax-logging-api]
16:58:10.097 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.ops4j.base]
16:58:10.097 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.ops4j.pax.swissbox.core]
16:58:10.097 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.ops4j.pax.swissbox.extender]
16:58:10.100 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.ops4j.pax.swissbox.framework]
16:58:10.100 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.ops4j.pax.swissbox.lifecycle]
16:58:10.100 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.ops4j.pax.swissbox.tracker]
16:58:10.100 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.apache.geronimo.specs.geronimo-atinject_1.0_spec]
16:58:10.101 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.ops4j.pax.tipi.junit]
16:58:10.102 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.apache.commons.lang]
16:58:10.103 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.apache.commons.collections]
16:58:10.105 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.apache.commons.beanutils]
16:58:10.106 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.apache.commons.io]
16:58:10.106 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [ch.qos.logback.core]
16:58:10.106 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [ch.qos.logback.classic]
16:58:10.106 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [slf4j.api]
16:58:10.107 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [jcl.over.slf4j]
16:58:10.116 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Starting blueprint extender...
16:58:10.288 [FelixStartLevel] INFO  o.a.a.b.container.BlueprintExtender - No quiesce support is available, so blueprint components will not participate in quiesce operations
16:58:10.289 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Blueprint extender started
16:58:10.289 [FelixStartLevel] DEBUG o.o.p.s.extender.BundleWatcher - Scanning bundle [org.apache.aries.blueprint]
16:58:10.293 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Found ProxyManager service, starting to process blueprint bundles
16:58:10.295 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.apache.felix.framework for blueprint application
16:58:10.298 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.apache.felix.framework
16:58:10.298 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.ops4j.pax.exam for blueprint application
16:58:10.299 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.ops4j.pax.exam
16:58:10.300 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.ops4j.pax.exam.inject for blueprint application
16:58:10.300 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.ops4j.pax.exam.inject
16:58:10.300 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.ops4j.pax.exam.extender.service for blueprint application
16:58:10.300 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.ops4j.pax.exam.extender.service
16:58:10.300 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle osgi.cmpn for blueprint application
16:58:10.312 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle osgi.cmpn
16:58:10.312 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.ops4j.pax.logging.pax-logging-api for blueprint application
16:58:10.313 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.ops4j.pax.logging.pax-logging-api
16:58:10.313 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.ops4j.base for blueprint application
16:58:10.314 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.ops4j.base
16:58:10.314 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.ops4j.pax.swissbox.core for blueprint application
16:58:10.315 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.ops4j.pax.swissbox.core
16:58:10.315 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.ops4j.pax.swissbox.extender for blueprint application
16:58:10.315 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.ops4j.pax.swissbox.extender
16:58:10.315 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.ops4j.pax.swissbox.framework for blueprint application
16:58:10.315 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.ops4j.pax.swissbox.framework
16:58:10.315 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.ops4j.pax.swissbox.lifecycle for blueprint application
16:58:10.316 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.ops4j.pax.swissbox.lifecycle
16:58:10.316 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.ops4j.pax.swissbox.tracker for blueprint application
16:58:10.316 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.ops4j.pax.swissbox.tracker
16:58:10.316 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.apache.geronimo.specs.geronimo-atinject_1.0_spec for blueprint application
16:58:10.316 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.apache.geronimo.specs.geronimo-atinject_1.0_spec
16:58:10.316 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.apache.commons.lang for blueprint application
16:58:10.317 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.apache.commons.lang
16:58:10.317 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.apache.commons.collections for blueprint application
16:58:10.326 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.apache.commons.collections
16:58:10.327 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.apache.commons.beanutils for blueprint application
16:58:10.330 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.apache.commons.beanutils
16:58:10.330 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.apache.commons.io for blueprint application
16:58:10.330 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle org.apache.commons.io
16:58:10.330 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle ch.qos.logback.core for blueprint application
16:58:10.331 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle ch.qos.logback.core
16:58:10.331 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle ch.qos.logback.classic for blueprint application
16:58:10.331 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle ch.qos.logback.classic
16:58:10.332 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle slf4j.api for blueprint application
16:58:10.332 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle slf4j.api
16:58:10.332 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle jcl.over.slf4j for blueprint application
16:58:10.332 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - No blueprint application found in bundle jcl.over.slf4j
16:58:10.332 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Starting BlueprintContainer destruction process for bundle null
16:58:10.332 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Not a blueprint bundle or destruction of BlueprintContainer already finished for null.
16:58:10.332 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Starting BlueprintContainer destruction process for bundle null
16:58:10.332 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Not a blueprint bundle or destruction of BlueprintContainer already finished for null.
16:58:10.332 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scanning bundle org.apache.aries.blueprint for blueprint application
16:58:10.335 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Found blueprint application in bundle org.apache.aries.blueprint with paths: [bundle://23.0:0/OSGI-INF/blueprint/blueprint-cm.xml, bundle://23.0:0/OSGI-INF/blueprint/blueprint-ext.xml]
16:58:10.351 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Scheduling creation of blueprint bundle org.apache.aries.blueprint asynchronously
org.osgi.framework.BundleException: Unresolved constraint in bundle base [26]: Unable to resolve 26.0: missing requirement [26.0] osgi.wiring.package; (osgi.wiring.package=net.sf.ehcache)
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)
    at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1191)
    at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295)
    at java.lang.Thread.run(Thread.java:745)
16:58:10.355 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Starting BlueprintContainer destruction process for bundle org.apache.aries.util
16:58:10.355 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Not a blueprint bundle or destruction of BlueprintContainer already finished for org.apache.aries.util.
16:58:10.355 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Starting BlueprintContainer destruction process for bundle base
16:58:10.355 [FelixStartLevel] DEBUG o.a.a.b.container.BlueprintExtender - Not a blueprint bundle or destruction of BlueprintContainer already finished for base.

共有1个答案

陆俊捷
2023-03-14

我通过将ehcache版本升级到2.8.5的最新版本,成功地解决了这个问题。ehcache core期望的版本比我使用的1.5.2版本的ehcache要高
对于像我这样的osgi初学者来说,更大的问题是没有得到正确的错误消息,这让我不得不花很多时间进行调查。

 类似资料:
  • 我对ivy没有解析我的一些依赖关系有问题。以下是我如何重现这个问题的: 我在eclipse中有一个空的java项目。我已经在我的项目中添加了ivy.xml: 这工作正常,ivy能够解决和下载口水。 如果我将修订版更改为6.3.0.Final(http://mvnrepository.com/artifact/org.drools/drools-core/6.3.0.Final),它将不起作用,我看

  • 我在Eclipse4.18中遇到了一个奇怪的问题,我希望有人能帮我解决这个问题。我的项目是一个jetty webapp,它通过FTP与外部服务器进行通信。我正在使用mockftpserver(https://mockftpserver.org/)帮助对需要与FTP服务器通信的代码进行单元测试。 我在pom中将库依赖项定义为 然后我在测试类中定义了一个导入,比如 没有什么太奇怪的事情发生,maven

  • 我有以下方法,它采用UNIX时间戳并以天、小时或分钟的形式返回年龄。我想用JUnit单元测试它,但我不确定如何开始这样做,因为当前时间不断变化。有什么建议吗?谢谢! 方法如下: }

  • 单元测试的正确方法是什么?理想情况下,我只想验证某个程序的(模拟)实例调用了主方法中的run()方法。我知道我可以创建一个setter来设置某个程序的实例,但是它看起来像一种代码味道,因为它除了启用更容易的测试之外没有做任何事情?与run()方法上的公共访问器相同。为了测试的目的,它是自由的。如果它是私人的,我如何测试它?我正在寻找类的变化,也许应用一些设计模式来缓解这个问题。

  • 很高兴有一个更新的Android Studio 3.0。但是我在Android Studio 3.0中遇到了一个问题,我刚刚在Android Studio 3.0中创建了一个新项目。然后我犯了一些错误 我通过将依赖项更改为最新版本并解决问题来解决这些问题。 但是,当我添加了facebook帐户工具包sdk的依赖项时。脸谱网。android:帐户工具包sdk:4 我收到以下错误-: 错误:无法解析“

  • 詹金斯1.500版有问题。我正在尝试建立一个依赖于我的另一个项目的项目。错误是: