2013-02-20 50 views
1

我正在嘗試使用Pax Exam來創建一個考試,其中一些我正在加載的考試包取決於包「org.apache.felix.ipojo」。在Pax考試中加載ipojo Maven Bundle

如果我要留出了一條在大同考試的配置加載此包,例如:

@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") 
      ... 

我得到一個消息indicatin g ClassCastException,我認爲這是由於在Felix中構建了ipojo包。

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作爲跑步者。

如何在沒有衝突的情況下訪問此依賴項?

+0

你解決了嗎?克萊門特的回答對你的案子有幫助嗎?在嘗試集成pax-exam和iPojo時,我面臨着類似的問題,我正在拼命尋找一個可行的例子。 – benjamin 2013-07-16 09:20:54

回答

0

這是我使用的:

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

用下面的版本:1.8.6 iPOJO和OSGi的助手0.6.0

的助手正在寫的OSGi測試時的減負方法。

1

ClassCastException最有可能表示您在類路徑中有另一個OSGi API副本。如果您對org.osgi:org.osgi.core有Maven依賴關係,請確保範圍是provided而不是compiletest