0 Replies Latest reply: Apr 23, 2013 12:34 PM by ramzibk RSS

    Error while testing with glassfish embedded

    ramzibk
      Hi,

      I am developping an enterprise application using netbeans 7.2.1 maven2 and glassfish3.
      To want to test persistance entities and i used Arquillian with glassfish profile.
      I created only one test for one entity class following this tutorial:
      http://arquillian.org/guides/testing_java_persistence/

      This is test class:
      @RunWith(Arquillian.class)
      public class AlertPersistanceTest {

      @PersistenceContext
      EntityManager em;

      @Inject
      UserTransaction utx;

      @Deployment
      public static Archive<?> createDeployment() {
      return ShrinkWrap.create(WebArchive.class, "test.war")
      .addPackage(Alert.class.getPackage())
      .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
      }

      public AlertPersistanceTest() {
      }

      @org.junit.BeforeClass
      public static void setUpClass() throws Exception {
      }

      @org.junit.AfterClass
      public static void tearDownClass() throws Exception {
      }

      @org.junit.Before
      public void setUp() throws Exception {
      }

      @org.junit.After
      public void tearDown() throws Exception {
      }

      @Test
      public void testIt(){
      Assert.assertEquals(1, 1);
      }

      }

      When i run the test i get this error:
      -------------------------------------------------------
      T E S T S
      -------------------------------------------------------
      Running com.procc.flams.jpa.AlertPersistanceTest
      INFO: Hibernate Validator 4.2.0.Final
      INFO: Network listener https-listener on port 0 disabled per domain.xml
      INFO: Grizzly Framework 1.9.46 started in: 123ms - bound to [0.0.0.0:8181]
      INFO: GlassFish Server Open Source Edition 3.1.2 (java_re-private) startup time : Embedded (2 186ms), startup services(1 265ms), total(3 451ms)
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.903 sec <<< FAILURE!

      Results :

      Tests in error:
      com.procc.flams.jpa.AlertPersistanceTest: injection failed on class com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl from sun.misc.Launcher$AppClassLoader@397b6178

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

      Here is pom.xml that i use for EJB module contaning entities and test classes:
      <?xml version="1.0" encoding="UTF-8"?>
      <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>
      <parent>
      <artifactId>FLAMS</artifactId>
      <groupId>com.procc</groupId>
      <version>1.0-SNAPSHOT</version>
      </parent>

      <groupId>com.procc</groupId>
      <artifactId>FLAMS-ejb</artifactId>
      <version>1.0-SNAPSHOT</version>
      <packaging>ejb</packaging>

      <name>FLAMS-ejb</name>

      <properties>
      <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
      </properties>

      <!-- clip -->
      <dependencyManagement>
      <dependencies>
      <dependency>
      <groupId>org.jboss.arquillian</groupId>
      <artifactId>arquillian-bom</artifactId>
      <version>1.0.3.Final</version>
      <scope>import</scope>
      <type>pom</type>
      </dependency>
      </dependencies>
      </dependencyManagement>
      <!-- clip -->

      <dependencies>

      <!-- clip -->
      <dependency>
      <groupId>org.jboss.arquillian.junit</groupId>
      <artifactId>arquillian-junit-container</artifactId>
      <scope>test</scope>
      </dependency>
      <!-- clip -->
      <!-- clip -->
      <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-jpamodelgen</artifactId>
      <version>1.2.0.Final</version>
      <scope>provided</scope>
      </dependency>
      <!-- clip -->
      <!-- clip -->
      <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>
      <!-- clip -->
      <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
      </dependency>
      </dependencies>

      <build>
      <plugins>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.2</version>
      <configuration>
      <source>1.6</source>
      <target>1.6</target>
      <compilerArguments>
      <endorseddirs>${endorsed.dir}</endorseddirs>
      </compilerArguments>
      </configuration>
      </plugin>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-ejb-plugin</artifactId>
      <version>2.3</version>
      <configuration>
      <ejbVersion>3.1</ejbVersion>
      </configuration>
      </plugin>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <version>2.1</version>
      <executions>
      <execution>
      <phase>validate</phase>
      <goals>
      <goal>copy</goal>
      </goals>
      <configuration>
      <outputDirectory>${endorsed.dir}</outputDirectory>
      <silent>true</silent>
      <artifactItems>
      <artifactItem>
      <groupId>javax</groupId>
      <artifactId>javaee-endorsed-api</artifactId>
      <version>6.0</version>
      <type>jar</type>
      </artifactItem>
      </artifactItems>
      </configuration>
      </execution>
      </executions>
      </plugin>
      </plugins>
      </build>

      <!-- clip -->
      <profiles>
      <profile>
      <id>arquillian-glassfish-embedded</id>
      <activation>
      <activeByDefault>true</activeByDefault>
      </activation>
      <dependencies>
      <dependency>
      <groupId>org.jboss.arquillian.container</groupId>
      <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
      <version>1.0.0.CR3</version>
      </dependency>
      <dependency>
      <groupId>org.glassfish.main.extras</groupId>
      <artifactId>glassfish-embedded-web</artifactId>
      <version>3.1.2</version>
      </dependency>
      </dependencies>
      <build>
      <testResources>
      <testResource>
      <directory>src/test/resources</directory>
      </testResource>
      <testResource>
      <directory>src/test/resources-glassfish-embedded</directory>
      </testResource>
      </testResources>
      <plugins>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <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>
      <!-- clip -->

      </project>


      please help,
      thanks.

      Edited by: ramzibk on 23 avr. 2013 10:32