0 Replies Latest reply on Apr 24, 2015 5:13 AM by akrima

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

    akrima Newbie

      I try to implements the Arquillian into my project to do the unite tests but when i clean install the pom.xml of my project it gives me that errors:

       

      Running TestSuite

      Tests run: 6, Failures: 1, Errors: 0, Skipped: 5, Time elapsed: 0.506 sec <<< FAILURE!

      arquillianBeforeSuite(com.aka.test.examples.GameServiceTest)  Time elapsed: 0.441 sec  <<< FAILURE!

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

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

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

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

          at org.jboss.arquillian.testng.Arquillian.arquillianBeforeSuite(Arquillian.java:70)

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

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

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

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

          at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)

          at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:552)

          at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)

          at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:140)

          at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)

          at org.testng.SuiteRunner.run(SuiteRunner.java:254)

          at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

          at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)

          at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)

          at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)

          at org.testng.TestNG.run(TestNG.java:1057)

          at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:178)

          at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92)

          at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:96)

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

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

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

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

          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:115)

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

      Caused by: java.lang.reflect.InvocationTargetException

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

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

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

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

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

          ... 30 more

      Caused by: org.jboss.arquillian.container.impl.ContainerCreationException: Could not create Container glassfish-embedded

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

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

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

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

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

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

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

          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:145)

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

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

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

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

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

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

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

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

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

          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:145)

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

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

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

          ... 35 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:80)

          ... 59 more

      Caused by: java.lang.reflect.InvocationTargetException

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

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

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

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

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

          ... 30 more

      Caused by: org.jboss.arquillian.container.impl.ContainerCreationException: Could not create Container glassfish-embedded

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

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

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

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

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

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

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

          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:145)

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

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

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

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

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

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

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

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

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

          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:145)

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

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

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

          ... 35 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:80)

          ... 59 more

       

       

      Results :

       

      Failed tests:   arquillianBeforeSuite(com.aka.test.examples.GameServiceTest): Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor

       

      Tests run: 6, Failures: 1, Errors: 0, Skipped: 5

       

      And the pom.xml of my services project (maven):


      <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/xsd/maven-4.0.0.xsd">

          <modelVersion>4.0.0</modelVersion>

          <groupId>com.aka</groupId>

          <artifactId>aka-Services</artifactId>

          <version>0.0.1</version>

          <name>aka-Services</name>

       

          <properties>

              <maven.surefire.plugin.version>2.12</maven.surefire.plugin.version>

              <maven.compiler.plugin.version>2.3.2</maven.compiler.plugin.version>

              <maven-ejb-plugin.version>2.1</maven-ejb-plugin.version>

              <ejb.version>3.0</ejb.version>

          </properties>

       

          <dependencies>

              <dependency>

                  <groupId>com.aka</groupId>

                  <artifactId>aka-Models</artifactId>

                  <version>0.0.1</version>

                  <scope>provided</scope>

              </dependency>

              <dependency>

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

                  <artifactId>arquillian-testng-container</artifactId>

              </dependency>

              <dependency>

                  <groupId>org.testng</groupId>

                  <artifactId>testng</artifactId>

                  <version>6.8.21</version>

              </dependency>

              <dependency>

                  <groupId>javax.inject</groupId>

                  <artifactId>javax.inject</artifactId>

                  <version>1</version>

              </dependency>

              <dependency>

                  <groupId>javax.transaction</groupId>

                  <artifactId>transaction-api</artifactId>

                  <version>1.1-rev-1</version>

              </dependency>

          </dependencies>

       

          <dependencyManagement>

              <dependencies>

                  <dependency>

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

                      <artifactId>arquillian-bom</artifactId>

                      <version>1.1.8.Final</version>

                      <scope>import</scope>

                      <type>pom</type>

                  </dependency>

              </dependencies>

          </dependencyManagement>

       

          <build>

          <defaultGoal>test</defaultGoal>

              <sourceDirectory>src</sourceDirectory>

              <testSourceDirectory>src/test/java</testSourceDirectory>

              <resources>

                  <resource>

                      <directory>src</directory>

                      <excludes>

                          <exclude>**/*.java</exclude>

                      </excludes>

                  </resource>

              </resources>

              <plugins>

                  <plugin>

                      <artifactId>maven-compiler-plugin</artifactId>

                      <version>${maven.compiler.plugin.version}</version>

                      <configuration>

                          <source>1.7</source>

                          <target>1.7</target>

                          <encoding>Cp1252</encoding>

                      </configuration>

                  </plugin>

                  <plugin>

                      <artifactId>maven-ejb-plugin</artifactId>

                      <version>${maven-ejb-plugin.version}</version>

                      <configuration>

                          <ejbVersion>${ejb.version}</ejbVersion>

                      </configuration>

                  </plugin>

       

                  <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

                      <artifactId>maven-shade-plugin</artifactId>

                      <executions>

                          <execution>

                              <phase>package</phase>

                              <goals>

                                  <goal>shade</goal>

                              </goals>

                          </execution>

                      </executions>

                      <configuration>

                          <artifactSet>

                              <includes>

                                  <include>com.aka</include>

                              </includes>

                          </artifactSet>

                          <finalName>${artifactId}-${project.version}</finalName>

                      </configuration>

                  </plugin>

       

                  <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

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

                      <configuration>

                          <skip>false</skip>

                          <childDelegation>true</childDelegation>

                          <useSystemClassLoader>true</useSystemClassLoader>

                          <argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true</argLine>

                          <suiteXmlFiles>

                              <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>

                          </suiteXmlFiles>

                      </configuration>

                  </plugin>

       

              </plugins>

          </build>

       

          <profiles>

              <profile>

                  <id>arquillian-glassfish-embedded</id>

                  <dependencies>

                      <dependency>

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

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

                          <version>1.0.0.CR2</version>

                          <scope>test</scope>

                      </dependency>

                      <dependency>

                          <groupId>org.glassfish.main.extras</groupId>

                          <artifactId>glassfish-embedded-all</artifactId>

                          <version>3.1.2</version>

                          <scope>provided</scope>

                      </dependency>

                      <dependency>

                          <groupId>com.h2database</groupId>

                          <artifactId>h2</artifactId>

                          <version>1.3.166</version>

                          <scope>test</scope>

                      </dependency>

                  </dependencies>

                  <build>

                      <testResources>

                          <testResource>

                              <directory>src/test/resources</directory>

                          </testResource>

                          <testResource>

                              <directory>src/test/resources-glassfish-embedded</directory>

                          </testResource>

                      </testResources>

                      <plugins>

                          <!-- The surefire plugin is configured to pass a system property to

                              GlassFish to retarget the derby log file -->

                          <plugin>

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

                              <version>2.12</version>

                              <configuration>

                                  <systemPropertyVariables>

                                      <java.util.logging.config.file>

                                          ${project.build.testOutputDirectory}/logging.properties

                                      </java.util.logging.config.file>

                                      <derby.stream.error.file>

                                          ${project.build.directory}/derby.log

                                      </derby.stream.error.file>

                                  </systemPropertyVariables>

                              </configuration>

                          </plugin>

                      </plugins>

                  </build>

              </profile>

          </profiles>

      </project>

       

      My Model class whitch is into the aka-models project:


      @Entity

      public class Game implements Serializable {   

          @Column(name="ID_GAME",nullable=false)

          private Long id;

          @Column(name="TITLE",nullable=false)

          private String title;

       

          public Game() {}

       

          public Game(String title) {

              this.title = title;

          }

          @Id @GeneratedValue

          public Long getId() {

              return id;

          }

          public void setId(Long id) {

              this.id = id;

          }

          public String getTitle() {

              return title;

          }

          public void setTitle(String title) {

              this.title = title;

          }

          @Override

          public String toString() {

              return "Game@" + hashCode() +

                  "[id = " + id + "; title = " + title + "]";

          }

      }


       

      My test class:


      import javax.inject.Inject;

      import javax.persistence.EntityManager;

      import javax.persistence.PersistenceContext;

      import javax.transaction.UserTransaction;

       

      import org.jboss.arquillian.container.test.api.Deployment;

      import org.jboss.arquillian.testng.Arquillian;

      import org.jboss.shrinkwrap.api.Archive;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.asset.EmptyAsset;

      import org.jboss.shrinkwrap.api.spec.JavaArchive;

      import org.testng.Assert;

      import org.testng.annotations.AfterTest;

      import org.testng.annotations.BeforeTest;

      import org.testng.annotations.Test;

       

      import com.aka.example.Game;

      import com.aka.interfaces.examples.IGameService;

       

      public class GameServiceTest extends Arquillian{

         

          @Deployment

          public static Archive<?> createDeployment() {

              JavaArchive jar = ShrinkWrap.create(JavaArchive.class)

                  .addPackage(Game.class.getPackage())

                  .addAsManifestResource("test-persistence.xml", "persistence.xml")

                  .addAsManifestResource("jbossas-ds.xml")

                  .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

              return jar;

          }

         

          @PersistenceContext(name="service-akaTest")

          EntityManager em;

         

          @Inject

          UserTransaction utx;

         

          @Inject

          IGameService gameService;

         

          private static final String[] GAME_TITLES = {

              "Super Mario Brothers",

              "Mario Kart",

              "F-Zero"

          };

         

          @BeforeTest

          public void preparePersistenceTest() throws Exception {

              //clearData();

              insertData();

              startTransaction();

          }

          private void clearData() throws Exception {

              utx.begin();

              em.joinTransaction();

              System.out.println("Dumping old records...");

              em.createQuery("delete from Game").executeUpdate();

              utx.commit();

          }

       

          private void insertData() throws Exception {

              utx.begin();

              em.joinTransaction();

              System.out.println("Inserting records...");

              for (String title : GAME_TITLES) {

                  Game game = new Game(title);

                  em.persist(game);

              }

              utx.commit();

              // reset the persistence context (cache)

              em.clear();

          }

          private void startTransaction() throws Exception {

              utx.begin();

              em.joinTransaction();

          }   

          @AfterTest

          public void commitTransaction() throws Exception {

              utx.commit();

          }   

          @Test

          public void CheckTitle(){

              Assert.assertTrue(true);

          } 

       

      }


      The Arquilliant.xml:


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

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

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

          xsi:schemaLocation="

              http://jboss.org/schema/arquillian

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

       

          <container qualifier="glassfish-embedded" default="true">

              <configuration>

                  <property name="resourcesXml">

                      src/test/resources-glassfish-embedded/glassfish-resources.xml

                  </property>

              </configuration>

          </container>

      </arquillian>


      The jboss-ds.xml:


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

      <datasources xmlns="http://www.jboss.org/ironjacamar/schema"

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

          xsi:schemaLocation="

              http://www.jboss.org/ironjacamar/schema

              http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">

          <datasource enabled="true"

              jndi-name="jdbc/arquillian"

              pool-name="ArquillianEmbeddedH2Pool">

              <connection-url>jdbc:h2:mem:arquillian;DB_CLOSE_DELAY=-1</connection-url>

              <driver>h2</driver>

          </datasource>

      </datasources>

       

      The testng.xml:


      <suite name="Suite" >

          <test name="Test" >

              <packages>

                  <package name="com.akrima.test.examples.*" />

              </packages>

          </test>

      </suite>


       

      The glassfish-resources.xml:

       

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

      <!DOCTYPE resources PUBLIC

          "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN"

          "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">

      <resources>

      <!--     <jdbc-resource pool-name="ArquillianEmbeddedDerbyPool" -->

      <!--         jndi-name="jdbc/arquillian"/> -->

      <!--     <jdbc-connection-pool name="ArquillianEmbeddedDerbyPool" -->

      <!--         res-type="javax.sql.DataSource" -->

      <!--         datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource" -->

      <!--         is-isolation-level-guaranteed="false"> -->

      <!--         <property name="databaseName" value="target/databases/derby"/> -->

      <!--         <property name="createDatabase" value="create"/> -->

      <!--     </jdbc-connection-pool> -->

       

         

          <jdbc-resource pool-name="ArquillianEmbeddedH2Pool"

              jndi-name="jdbc/arquillian"/>

          <jdbc-connection-pool name="ArquillianEmbeddedH2Pool"

              res-type="javax.sql.DataSource"

              datasource-classname="org.h2.jdbcx.JdbcDataSource">

              <property name="user" value="sa"/>

              <property name="password" value=""/>

              <property name="url" value="jdbc:h2:file:target/databases/h2/db"/>

          </jdbc-connection-pool>

         

      </resources>

       

      The test-persistence.xml:

       

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

      <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"

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

          xsi:schemaLocation="

              http://java.sun.com/xml/ns/persistence

              http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

          <persistence-unit name="service-akrimaTest">

              <jta-data-source>jdbc/arquillian</jta-data-source>

              <properties>

                  <property name="hibernate.hbm2ddl.auto" value="create-drop"/>

                  <property name="hibernate.show_sql" value="true"/>

              </properties>

          </persistence-unit>

      </persistence>