【问题标题】:Loading ipojo Maven Bundle in Pax Exam Test在 Pax 考试测试中加载 ipojo Maven Bundle
【发布时间】:2013-02-04 21:09:18
【问题描述】:

我正在尝试使用 Pax Exam 创建一个测试,其中我为测试加载的一些包依赖于包“org.apache.felix.ipojo”。

如果我要在 Pax Exam 配置中省略加载此捆绑包的行,例如:

@Configuration
public Option[] config() throws MalformedURLException{
    return options(
            junitBundles(),
            BUNDLES OTHER THAN(org.apache.felix.ipojo),
            ...

然后我得到一个错误,表明这个包缺少依赖:

ERROR: Bundle com.N.A [35] Error starting mvn:com.N/com.N.A (org.osgi.framework.BundleException: Unresolved constraint in bundle com.N.A [35]: Unable to resolve 35.0: missing requirement [35.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.felix.ipojo)(version>=1.8.0)))
org.osgi.framework.BundleException: Unresolved constraint in bundle com.N.A [35]: Unable to resolve 35.0: missing requirement [35.0] osgi.wiring.package; (&(osgi.wiring.package=org.apache.felix.ipojo)(version>=1.8.0))
        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:662)

但是,如果我添加包含它的行:

@Configuration
public Option[] config() throws MalformedURLException{
    return options(
            junitBundles(),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo")
            ...

我收到一条指示 ClassCastException 的消息,我认为这是由于 ipojo 捆绑包内置到 Felix 中所致。

ERROR: Bundle org.apache.felix.ipojo [34] Error starting mvn:org.apache.felix/org.apache.felix.ipojo (org.osgi.framework.BundleException: Activator start error in bundle org.apache.felix.ipojo [34].)
java.lang.ClassCastException: org.apache.felix.ipojo.Extender cannot be cast to org.osgi.framework.BundleActivator
        at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4177)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:1972)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
        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:662)

我正在使用 Felix 和 JUint4TestRunner 作为跑步者。

如何在不发生冲突的情况下访问此依赖项?

【问题讨论】:

  • 你解决了吗?克莱门特的回答对您有帮助吗?在尝试集成 pax-exam 和 iPojo 时,我遇到了类似的问题,我正在拼命寻找一个可行的示例。

标签: apache-felix pax-exam pax-runner ipojo


【解决方案1】:

这是我使用的:

public CompositeOption ipojoBundles() {
    return new DefaultCompositeOption(
            mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
            mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject());
}

具有以下版本:iPOJO 1.8.6 和 osgi-helpers 0.6.0

帮助程序是在编写 OSGi 测试时减轻负担的方法。

【讨论】:

    【解决方案2】:

    ClassCastException 很可能表明您的类路径上有另一个 OSGi API 副本。如果您对 org.osgi:org.osgi.core 有 Maven 依赖项,请确保范围是 provided 而不是 compiletest

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-03
      • 2019-05-26
      • 2014-08-14
      • 2015-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-19
      相关资源
      最近更新 更多