7 Replies Latest reply on Apr 18, 2012 9:28 AM by Aslak Knutsen

    Exception when running tests in Jenkins

    Gerard Boanoro Newbie

      Hi,

       

      I am trying Arquillian in order to introduce it in our testing process. I managed to successfully run some integration tests from Eclipse, but when I do the same in Jenkins, I get the following exception:

       

      Could not create a new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor see cause.

      java.lang.RuntimeException: Could not create a new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor see cause.

      at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:170)

      at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)

      at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:93)

      at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)

      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)

      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:597)

      at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)

      at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)

      at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)

      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)

      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)

      Caused by: java.lang.reflect.InvocationTargetException

      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

      at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:166)

      ... 14 more

      Caused by: org.jboss.arquillian.container.impl.ContainerCreationException: Could not create Container myjboos7

      at org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:85)

      at org.jboss.arquillian.container.impl.client.container.ContainerRegistryCreator.createRegistry(ContainerRegistryCreator.java:75)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:597)

      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)

      at org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:235)

      at org.jboss.arquillian.core.impl.InstanceImpl.set(InstanceImpl.java:74)

      at org.jboss.arquillian.config.impl.extension.ConfigurationRegistrar.loadConfiguration(ConfigurationRegistrar.java:68)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:597)

      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)

      at org.jboss.arquillian.core.impl.ManagerImpl.start(ManagerImpl.java:260)

      at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:56)

      ... 19 more

      Caused by: java.lang.IllegalArgumentException: DeployableContainer must be specified

      at org.jboss.arquillian.core.spi.Validate.notNull(Validate.java:44)

      at org.jboss.arquillian.container.impl.ContainerImpl.<init>(ContainerImpl.java:71)

      at org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:76)

      ... 43 more

      Caused by: java.lang.reflect.InvocationTargetException

      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

      at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:166)

      ... 14 more

      Caused by: org.jboss.arquillian.container.impl.ContainerCreationException: Could not create Container myjboos7

      at org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:85)

      at org.jboss.arquillian.container.impl.client.container.ContainerRegistryCreator.createRegistry(ContainerRegistryCreator.java:75)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:597)

      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)

      at org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:235)

      at org.jboss.arquillian.core.impl.InstanceImpl.set(InstanceImpl.java:74)

      at org.jboss.arquillian.config.impl.extension.ConfigurationRegistrar.loadConfiguration(ConfigurationRegistrar.java:68)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:597)

      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:90)

      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:134)

      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:114)

      at org.jboss.arquillian.core.impl.ManagerImpl.start(ManagerImpl.java:260)

      at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:56)

      ... 19 more

      Caused by: java.lang.IllegalArgumentException: DeployableContainer must be specified

      at org.jboss.arquillian.core.spi.Validate.notNull(Validate.java:44)

      at org.jboss.arquillian.container.impl.ContainerImpl.<init>(ContainerImpl.java:71)

      at org.jboss.arquillian.container.impl.LocalContainerRegistry.create(LocalContainerRegistry.java:76)

      ... 43 more

       

       

      I tried to change the configuration based on several discussions on the forum, but I couldn't make it work. Any help would be great!

       

      I am deploying on JBossAS 7.0.2. Here is the arquilian.xml

       

      {code:xml}

      <?xml version="1.0" encoding="UTF-8"?>

      <arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xmlns="http://jboss.org/schema/arquillian"

                xsi:schemaLocation="http://jboss.org/schema/arquillian

                                    http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

       

       

       

       

          <container qualifier="myjboos7" default="true">

              <protocol type="jmx-as7">

                  <property name="executionType">REMOTE</property>

              </protocol>

              <configuration>

                  <property name="jbossHome">D:\apps\JBoss\jboss-as-web-7.0.2.Final</property>

                  <!-- Faster startup, is that actually used for MANAGED? -->

                  <property name="javaVmArguments">-d32 -noverify</property>

              </configuration>

          </container>

       

       

      </arquillian>

      {code}

       

      Here is the pom.xml:

       

      {code:xml}

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

        <modelVersion>4.0.0</modelVersion>

        <groupId>com.gege.common</groupId>

        <artifactId>example</artifactId>

        <packaging>jar</packaging>

        <version>1.0</version>

        <name>example</name>

        <url>http://maven.apache.org</url>

       

        <properties>

          <arquillian-version>1.0.0.CR7</arquillian-version>

          <jboss-as-version>7.0.2.Final</jboss-as-version>

          <junit-version>4.10</junit-version>

          <jmockit-version>0.999.13</jmockit-version>

        </properties>

       

        <dependencyManagement>

          <dependencies>

            <dependency>

              <groupId>org.jboss.arquillian</groupId>

              <artifactId>arquillian-bom</artifactId>

              <version>${arquillian-version}</version>

              <scope>import</scope>

              <type>pom</type>

            </dependency>

          </dependencies>

        </dependencyManagement>

         

        <dependencies>

          <dependency>

            <groupId>junit</groupId>

            <artifactId>junit</artifactId>

            <version>${junit-version}</version>

            <scope>test</scope>

          </dependency>

          <dependency>

            <groupId>com.googlecode.jmockit</groupId>

            <artifactId>jmockit</artifactId>

            <version>${jmockit-version}</version>

            <scope>test</scope>

          </dependency>   

          <dependency>

                  <groupId>org.jboss.logging</groupId>

                  <artifactId>jboss-logging</artifactId>

                  <version>3.1.0.CR2</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.logging</groupId>

            <artifactId>jboss-logging-log4j</artifactId>

            <version>2.2.0.CR1</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.logging</groupId>

            <artifactId>jboss-logging-spi</artifactId>

            <version>2.2.0.CR1</version>

          </dependency>

         

          <!--  -->

          <dependency>

          <groupId>org.jboss.arquillian.junit</groupId>

            <artifactId>arquillian-junit-container</artifactId>

            <version>${arquillian-version}</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.arquillian.container</groupId>

            <artifactId>arquillian-container-test-api</artifactId>

            <version>${arquillian-version}</version>

          </dependency>

         

          <!--  -->

          <dependency>

            <groupId>org.apache.openejb</groupId>

            <artifactId>openejb-core</artifactId>

            <version>4.0.0-beta-2</version>

          </dependency>

          <dependency>

            <groupId>javax.inject</groupId>

            <artifactId>javax.inject</artifactId>

            <version>1</version>

          </dependency>

          <dependency>

            <groupId>org.jboss.arquillian.container</groupId>

            <artifactId>arquillian-openejb-embedded-3.1</artifactId>

            <version>1.0.0.Alpha5</version>

            <scope>test</scope>

          </dependency>

         

        </dependencies>

        <profiles>

                  <profile>

                    <id>jbossas-remote-7</id>

                    <dependencies>

                        <dependency>

                            <groupId>org.jboss.spec</groupId>

                            <artifactId>jboss-javaee-6.0</artifactId>

                            <version>1.0.0.Final</version>

                            <type>pom</type>

                            <scope>provided</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.jboss.as</groupId>

                            <artifactId>jboss-as-arquillian-container-remote</artifactId>

                            <version>${jboss-as-version}</version>

                        </dependency>

                    </dependencies>

                </profile>

        </profiles>

        <repositories>

                  <repository>

                    <id>java.net</id>

            <url>http://download.java.net/maven/2</url>

                  </repository>

                  <repository>

                  <id>JBoss repository</id>

                  <url>http://repository.jboss.org/nexus/content/groups/public/</url>

                </repository>

        </repositories>

        <build>

         <plugins>

                    <plugin>

                      <artifactId>maven-surefire-plugin</artifactId>

                      <version>2.12</version>

             <configuration>

               <argLine>

                 -javaagent:"${settings.localRepository}"/com/googlecode/jmockit/jmockit/0.999.13/jmockit-0.999.13.jar

               </argLine>

             </configuration>

           </plugin>

         </plugins>

        </build> 

      </project>

      {code}

       

      Thank you in advance, guys!

        • 1. Re: Exception when running tests in Jenkins
          Aslak Knutsen Master

          Are you activating the "jbossas-remote-7" profile when you run your build?

          • 2. Re: Exception when running tests in Jenkins
            Gerard Boanoro Newbie

            Yes, you are right! Thank you!

             

            I added in the pom.xml

            ....

            {code:xml}

            <id>jbossas-remote-7</id>

                          <activation>

                           <activeByDefault>true</activeByDefault>

                          </activation>

                          <dependencies

            {code}

            .....

             

            Now, the tests are executing without errors. But when they are re-executed for Sonar, I got an exception that states at some point :

             

            ....

            Caused by: java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/HasBeenInstrumented

                      at java.lang.ClassLoader.defineClass1(Native Method) [:1.6.0_21]

                      at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) [:1.6.0_21]

                      at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [:1.6.0_21]

                      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [:1.6.0_21]

                      at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:397) [jboss-modules.jar:1.0.2.GA]

                      ... 15 more

            Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.HasBeenInstrumented from [Module "deployment.firstejb.jar:main" from Service Module Loader]

            ....

             

             

            I read that there are some issues concerning the integration with Cobertura.

             

            My next question is:is there a  way to get the code coverage in Sonar for integration tests using Arquillian?

            • 3. Re: Exception when running tests in Jenkins
              Gerard Boanoro Newbie

              After gathering information on the web, I changed the code coverage in Sonar from Cobertura to Jacoco and one of my two Arquillian-based tests is successful.

               

              Anyway, I can say that Arquillian is very useful. Congratulations for this great job!

              • 4. Re: Exception when running tests in Jenkins
                Aslak Knutsen Master

                Thank you!

                 

                Yes, Sonary Codecoverage should work when using Jacoco and the Arquillian Jacoco extension

                • 5. Re: Exception when running tests in Jenkins
                  Gerard Boanoro Newbie

                  It is strange. I read about the Arquillian Jacoco extension but I did not use it. And it seems the results I get both in Jenkins and in Sonar are correct. I changed the tests to see if the Sonar screen displays the correct results when they are failling. The code coverage seems correct also.

                   

                  Well, maybe I missed something but it is working without that extension. A little bit further investigation will anyway be needed.

                  • 6. Re: Exception when running tests in Jenkins
                    Kees Klerk Newbie

                    You can add the Cobertura library to your deployment war to fix the NoClassDefFoundError error

                     

                    WebArchive archive =
                                    ShrinkWrap.create(WebArchive.class, "demo.war")
                    
                    ....
                    
                    .addAsLibraries(
                                                    DependencyResolvers
                                                            .use(MavenDependencyResolver.class)
                                                            .artifacts("net.sourceforge.cobertura:cobertura:1.9.4.1")
                                                            .resolveAsFiles())
                    
                    

                     

                     

                    Now, the tests are executing without errors. But when they are re-executed for Sonar, I got an exception that states at some point :

                     

                    ....

                    Caused by: java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/HasBeenInstrumented

                              at java.lang.ClassLoader.defineClass1(Native Method) [:1.6.0_21]

                              at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) [:1.6.0_21]

                              at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [:1.6.0_21]

                              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [:1.6.0_21]

                              at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:397) [jboss-modules.jar:1.0.2.GA]

                              ... 15 more

                    Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.HasBeenInstrumented from [Module "deployment.firstejb.jar:main" from Service Module Loader]

                    ....

                     

                     

                    I read that there are some issues concerning the integration with Cobertura.

                     

                    My next question is:is there a  way to get the code coverage in Sonar for integration tests using Arquillian?