5 Replies Latest reply on Feb 7, 2012 12:29 PM by Thierry Wasylczenko

    Arquillian with GlassFish 3.0.1

    Thierry Wasylczenko Newbie

      Hello everyone,

       

      I'm trying to use Arquillian with GlassFish 3.0.1 and I can't get it works. After reading a lot of articles about how to configure Arquillian, I still have some troubles running some tests with Maven. Indeed i got an exception:

       

      Exception in thread "main" 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

       

      I've tried with both remote and embedded Glassfish. I'm also using NetBeans 7.1 (if this could be meaningful)

       

      My arquillian.xml:

       

      {code:xml}

      <?xml version="1.0"?>

      <arquillian xmlns="http://jboss.com/arquillian"

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

                  xsi:schemaLocation="http://jboss.org/schema/arquillian http://www.jboss.org/schema/arquillian/arquillian-1.0.xsd">

       

       

          <engine>

              <property name="deploymentExportPath">target/</property>

          </engine>

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

              <configuration>

                  <property name="configurationXml">src/test/resources/domain.xml</property>

              </configuration>

          </container>

      </arquillian>

      {code}

       

      In the configurationXml property I also tried to only put domain.xml.

       

      My pom.xml:

       

      {code:xml}

      <properties>

              <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>

              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

             

              <version.arquillian_core>1.0.0.CR7</version.arquillian_core>

             

              <version.glassfish>3.0.1</version.glassfish>

              <version.arquillian_container_glassfish>1.0.0.Alpha2</version.arquillian_container_glassfish>

          </properties>

       

          <repositories>

              <repository>

                  <id>jboss</id>

                  <name>JBOSS</name>

                  <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>

              </repository>

             

              <repository>

                  <id>Glassfish</id>

                  <name>Glassfish Repository</name>

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

              </repository>

          </repositories>

         

          <dependencies>

              <dependency>

                  <groupId>javax</groupId>

                  <artifactId>javaee-api</artifactId>

                  <version>6.0</version>

                  <scope>provided</scope>

              </dependency>

              <dependency>

                  <groupId>javax.enterprise</groupId>

                  <artifactId>cdi-api</artifactId>

                  <version>1.0-SP4</version>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>junit</groupId>

                  <artifactId>junit</artifactId>

                  <version>4.8.2</version>

                  <scope>test</scope>

              </dependency>

             

              <dependency>

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

                  <artifactId>arquillian-bom</artifactId>

                  <version>${version.arquillian_core}</version>

                  <scope>test</scope>

                  <type>pom</type>

              </dependency>

             

              <dependency>

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

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

                  <version>${version.arquillian_core}</version>

                  <scope>test</scope>

              </dependency>

             

              <dependency>

                  <groupId>org.glassfish.deployment</groupId>

                  <artifactId>deployment-client</artifactId>

                  <version>3.0.1</version>

                  <scope>test</scope>

              </dependency>

             

              <dependency>

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

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

                  <version>${version.arquillian_container_glassfish}</version>

                  <scope>test</scope>

              </dependency>

          </dependencies>

       

          <profiles>

              <profile>

                  <id>glassfish-remote-3.1</id>

                  <dependencies>

                      <dependency>

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

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

                          <version>${version.arquillian_container_glassfish}</version>

                          <scope>test</scope>

                      </dependency>

                      <dependency>

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

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

                          <version>3.0.1</version>

                      </dependency>

                  </dependencies>

              </profile>

          </profiles>

      {code}

       

      My Java class to test it:

       

      {code:java}

      @RunWith(Arquillian.class)

      public class MyEJBTester {

       

       

          @EJB

          private MyEJBRemote myEJB;

       

       

          @Deployment(name="glassfish")

          public static JavaArchive createTestArchive() {

              return ShrinkWrap.create(JavaArchive.class, "test.jar")

                      .addClasses(MyEJBRemote.class)

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

          }

         

          @Test

          public void sayHello() {

              Assert.assertEquals("Hello from my EJB", myEJB.sayHello());

          }

      }

      {code}