2 Replies Latest reply on Nov 12, 2013 4:07 PM by doegi

    How to force Arquillian to shutdown its embedded container

    mjremijan

      The project I am working on has a mix of Arquillian tests and tests which use EJBContainer directly.  When  execute `mvn test` I get test failures becuase of an org.glassfish.embeddable.GlassFishException: Already bootstrapped problem.  Looking at how the tests run, it is clear to see the Aquillian test run, then the EJBContainer tests run and then the EJBContainer tests fail with this exception. If you run them all individually they work fine.  I can only guess that the Glassfish container Arquillian starts is not being shut down.  So How do I do this?  I'd like to put an @AfterClass on my Arquillian test to make sure everying has been stopped.

        • 1. Re: How to force Arquillian to shutdown its embedded container
          aslak

          You could in theory configure the Arquillian Container to start/stop on class level by setting the mode on the container element in arquillian.xml

           

          <container mode="class">
          

           

          But that would of course start and stop the container for every Test Class. Might not be what you want.

           

          Another option would be to configure the build to have two executions, one that runs the arquillian tests and one that runs the other.

          Similar to:

           

            <build>
              <plugins>
                <plugin>
                  <artifactId>maven-surefire-plugin</artifactId>
                  <configuration>
                    <includes>
                      <include>**/non-arq/*TestCase*</include>
                    </includes>
                  </configuration>
                  <executions>
                    <execution>
                      <id>arquillian</id>
                      <goals>
                        <goal>test</goal>
                      </goals>
                      <phase>test</phase>
                      <configuration>
                       <includes>
                          <include>**/arquillian/*TestCase*</include>
                       </includes>
                      </configuration>
                    </execution>
                  </executions>
                </plugin>
              </plugins>
            </build>
          
          
          • 2. Re: How to force Arquillian to shutdown its embedded container
            doegi

            I came across this post after a google search for the "Already bootstrapped" error message.  After hours of searching for a solutions, I figured that the glassfish-embedded-container plugin for Arquillian tries to bootstrap the embedded Glassfish multiple times.  A simple workaround is to force a new JVM for each test class:

             

            <plugin>
              <artifactId>maven-surefire-plugin</artifactId>
              <version>2.16</version>
              <configuration>
              <reuseForks>false</reuseForks>
              </configuration>
            </plugin>