[arquillian-issues] [JBoss JIRA] (ARQ-1388) @EJB not working in embedded glassfish for @Remote Stateless beans if called more than twice

Dominik Kuhn (JIRA) jira-events at lists.jboss.org
Tue May 21 12:25:06 EDT 2013


Dominik Kuhn created ARQ-1388:
---------------------------------

             Summary: @EJB not working in embedded glassfish for @Remote Stateless beans if called more than twice
                 Key: ARQ-1388
                 URL: https://issues.jboss.org/browse/ARQ-1388
             Project: Arquillian
          Issue Type: Feature Request
      Security Level: Public (Everyone can see)
          Components: Base Implementation
    Affects Versions: glassfish_1.0.0.CR4, 1.0.3.Final
            Reporter: Dominik Kuhn


We have 20 testclasses. the ejb's are injected by the @EJB annotation.

If each testclass is run standalone (using eclipse), everything works and the tests are successful.

If all testclasses are run together (using eclipse or maven surefire plugin) the test fails after the first two testclasses with one of the two following error messages:

java.lang.NullPointerException
	at arqtest.test.GreeterTest5.test(GreeterTest5.java:23)
... 

or 
java.lang.IllegalArgumentException: ArquillianServletRunner not found. Could not determine ContextRoot from ProtocolMetadata, please contact DeployableContainer developer.
...


Error message is:

If I change the @Remote annotation of the stateless beans to @Local the tests are successful, even if run together.

To test this i created a very simple test project, which contains:

###### IGreeterService.java ######
package arqtest;

public interface IGreeterService {
    String sayHello();
}

###### GreeterService.java ######
package arqtest;

import java.io.Serializable;

import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;

@Stateless(name = "GreeterService")
@Local(IGreeterService.class)
@Remote(IGreeterService.class)
public class GreeterService implements Serializable, IGreeterService {

    private static final long serialVersionUID = 1L;

    @Override
    public String sayHello() {
	return "Hello";
    }
}

###### TestBase ######
package arqtest.test;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;

public class TestBase {
    private static EnterpriseArchive ear;
    private static JavaArchive jar;

    @Deployment(testable = true)
    // @OverProtocol("EJB 3.1")
    public static Archive<?> createArchive() {
	if (ear == null) {
	    jar = ShrinkWrap.create(JavaArchive.class, "test.jar");
	    jar.addPackages(true, "arqtest");
	    jar.addAsResource("META-INF/beans.xml");
	    jar.addAsResource("test-persistence.xml", ArchivePaths.create("META-INF/persistence.xml"));

	    // comment out when interested in content of archive
	    System.out.println(jar.toString(true));

	    ear = ShrinkWrap.create(EnterpriseArchive.class, "test.ear");
	    ear.addAsModule(jar);
	    System.out.println(ear.toString(true));
	}
	return ear;
    }
}

###### GreeterTest.java ######
## For demonstration I copied this class 10 times -->  GreeterTest1.java - GreeterTest9.java ##
package arqtest.test;

import static org.junit.Assert.assertEquals;

import javax.ejb.EJB;

import org.jboss.arquillian.junit.Arquillian;
import org.junit.Test;
import org.junit.runner.RunWith;

import arqtest.IGreeterService;

@RunWith(Arquillian.class)
// @RunAsClient
public class GreeterTest extends TestBase {

    @EJB(mappedName = "java:global/test/testejb/GreeterService")
    private IGreeterService greeter;

    @Test
    public final void test() {
	assertEquals("Hello", greeter.sayHello());
    }
}
###### arquillian.xml #####
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://www.jboss.org/arquillian-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
      http://www.jboss.org/arquillian-1.0
      http://www.jboss.org/schema/arquillian/arquillian-1.0.xsd">
  <defaultProtocol type="Servlet 3.0" />
  <container qualifier="glassfish" default="true">
    <configuration>
      <property name="bindHttpPort">9999</property>
    </configuration>
  </container>
  <engine>
    <deploymentExportPath>z:/temp/arquillian/</deploymentExportPath>
  </engine>
</arquillian>

##### pom.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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>arqtest</groupId>
  <artifactId>arqtest</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <name>ArqTest</name>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>2.3.2</version>
          <configuration>
            <source>1.7</source>
            <target>1.7</target>
            <compilerArguments>
              <endorseddirs>${endorsed.dir}</endorseddirs>
            </compilerArguments>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.13</version>
          <configuration></configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  <profiles>
    <profile>
      <id>complete</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.13</version>
            <configuration>
              <excludes>
                <exclude>**/live/*.java</exclude>
                <exclude>**/BaseStateTest.java</exclude>
              </excludes>
              <testFailureIgnore>true</testFailureIgnore>
              <outputDirectory>test-reports</outputDirectory>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-site-plugin</artifactId>
            <version>2.2</version>
          </plugin>
          <plugin>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <executions>
              <execution>
                <id>during-packaging</id>
                <phase>package</phase>
                <goals>
                  <goal>report</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <aggregate>true</aggregate>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
  <repositories>
    <repository>
      <id>apache-m2-snapshot</id>
      <name>Apache Snapshot Repository</name>
      <url>http://repository.apache.org/snapshots</url>
    </repository>
  </repositories>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
      <version>2.2.9</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jboss.arquillian</groupId>
      <artifactId>arquillian-bom</artifactId>
      <version>1.0.3.Final</version>
      <scope>import</scope>
      <type>pom</type>
    </dependency>
    <dependency>
      <groupId>org.jboss.arquillian.container</groupId>
      <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
      <version>1.0.0.CR4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jboss.arquillian.junit</groupId>
      <artifactId>arquillian-junit-container</artifactId>
      <version>1.0.3.Final</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.glassfish.main.extras</groupId>
      <artifactId>glassfish-embedded-all</artifactId>
      <version>3.1.2.2</version>
      <scope>provided</scope>
    </dependency>

    <!-- <dependency>
      <groupId>org.glassfish.extras</groupId>
      <artifactId>glassfish-embedded-all</artifactId>
      <version>3.2-b06</version>
      <scope>provided</scope>
      </dependency>
    -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.5.10</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
      <version>1.9.0</version>
    </dependency>
  </dependencies>
  <dependencyManagement />
  <properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
</project>



--> If possible, i'd like to upload my test project

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the arquillian-issues mailing list