1

OSGi testing with Pax-Exam Fails with "no container found error".

This happened because I upgraded form java 7 to java 8 and with that I had to change pax-exam-2.3.0.jar (which is not compatible with java 8) to pax-exam-4.4.0.jar. And their other dependency. Earlier in config we used to write felix() but that is changed now.

How to start felix container now?

Config:

@RunWith(PaxExam.class)
@ExamReactorStrategy(PerMethod.class)
public class GibsonMiniAGLTest
{
    @Configuration
    public Option[] config() {



        return options(


                vmOption("-Dcom.sun.management.jmxremote"),
                systemPackages("sun.misc",
                        "sun.security.util",
                        "sun.security.x509",
                        "com.sun.media.imageioimpl.plugins.jpeg2000"
                        ),
                bootDelegationPackages(
                    "sun.misc.*",
                    "com.sun.*"
                ),
                bundle("abc.jar"),
                junitBundles()

            );
    }
 }

Ant File:

<target name="run_STOSGI">
        <property file="build/jamunTimeOut.properties"/>
        <echo message="Calculated TimeOut for Jamun_Tests in MilliSeconds = ..........." />
        <echo message="${timeout}" />
        <junit printsummary="yes" showoutput="yes" timeout="${timeout}" haltonfailure="on" maxmemory="256M" fork="on">
            <jvmarg value="-Dorg.xml.sax.driver=${saxParser}" />
            <classpath>
                <pathelement path="${jamun.path}" />
                <pathelement path="${junit.path}" />
                <pathelement path="${jar}/core.jar" />
            </classpath>
            <formatter type="xml" />
            <sysproperty key="BAT_PLUGIN" value="${BAT_PLUGIN}"/>
            <test name="com.adobe.gibsontests.SmokeTestOSGIosgi" />
        </junit>
        <move todir="${smokeTest_Location}" failonerror="false" overwrite="true" >
            <fileset dir="${smoketest_temp}"/>
        </move>
    </target>

Stack trace:

  <testcase classname="com.adobe.gibsontests.SmokeTestOSGIosgi" name="initializationError" time="0.004">
    <error message="No TestContainer implementation in Classpath" type="org.ops4j.pax.exam.TestContainerException">org.ops4j.pax.exam.TestContainerException: No TestContainer implementation in Classpath
    at org.ops4j.pax.exam.spi.PaxExamRuntime.sanityCheck(PaxExamRuntime.java:266)
    at org.ops4j.pax.exam.spi.PaxExamRuntime.getTestContainerFactory(PaxExamRuntime.java:79)
    at org.ops4j.pax.exam.spi.reactors.ReactorManager.createsTestContainerFactory(ReactorManager.java:325)
    at org.ops4j.pax.exam.spi.reactors.ReactorManager.createReactor(ReactorManager.java:302)
    at org.ops4j.pax.exam.spi.reactors.ReactorManager.prepareReactor(ReactorManager.java:181)
    at org.ops4j.pax.exam.junit.impl.ProbeRunner.&lt;init&gt;(ProbeRunner.java:78)
    at org.ops4j.pax.exam.junit.PaxExam.createDelegate(PaxExam.java:82)
    at org.ops4j.pax.exam.junit.PaxExam.&lt;init&gt;(PaxExam.java:73)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

Can somebody point out what I am missing?

I tried running pax-exam in standalone and it failed there too with error: org.ops4j.pax.exam.TestContainerException: No service org.osgi.framework.launch.FrameworkFactory found in META-INF/services on classpath

Amrit Raj
  • 71
  • 1
  • 8

1 Answers1

1

As the error message states "No TestContainer implementation in Classpath". You need to put a container implementation onto the classpath.

There are a couple of options. The most basic ones are:

1.:

<dependency>
  <groupId>org.ops4j.pax.exam</groupId>
  <artifactId>pax-exam-container-native</artifactId>
  <scope>test</scope>
</dependency>

2.:

<dependency>
  <groupId>org.ops4j.pax.exam</groupId>
  <artifactId>pax-exam-container-forked</artifactId>
  <scope>test</scope>
</dependency>

There are also some more sophisticated ones like karaf container etc.

Jmini
  • 9,189
  • 2
  • 55
  • 77
aminator
  • 396
  • 7
  • 18