title: JUnit/Arquillian: Run managed Wildfly 8.1 container
body: <p>I'm trying to bring a simple test case to run:</p>
  
  <h3>Is there anywhere a clean set of instructions how to run Java EE integration tests on <em>managed Wildfly 8</em> containers?</h3>
  
  <ul>
  <li><p>I just want to run a simple test case via <code>mvn test</code> within a fresh, downloaded Wildfly container.</p></li>
  <li><p>The <a href="https://docs.jboss.org/author/display/ARQ/WildFly+8.1.0+-+Embedded" rel="nofollow">docs</a> say for the <em>embedded</em> case, the <em>maven-dependency-plugin</em>'s <code>unpack</code> goal can be used to download Wildfly and unzip it automatically.</p></li>
  <li><p>I want to make the container <em>managed</em> to be sure to have a separate JVM for test cases, managed by <em>Arquillian</em> itself.</p></li>
  </ul>
  
  <h3>Now where do I have to reference the Wildfly folder?</h3>
  
  <p>1) I could do it within my <code>test/resource/arquillian.xml</code> via:</p>
  
  <pre><code>&lt;container qualifier="arquillian-wildfly8-managed" default="true"&gt;
      &lt;configuration&gt;
          &lt;property name="jbossHome"&gt;target/wildfly-8.1.0.Final&lt;/property&gt;
          &lt;property name="modulePath"&gt;target/wildfly-8.1.0.Final/modules&lt;/property&gt;
      &lt;/configuration&gt;
  &lt;/container&gt;
  </code></pre>
  
  <p>2) Another way would be to configure the <em>surefire-plugin</em>'s system properties within the pom file: </p>
  
  <pre><code>&lt;plugin&gt;
     &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
     &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
     &lt;version&gt;2.17&lt;/version&gt;
     &lt;configuration&gt;
      &lt;property&gt;
          &lt;name&gt;jboss.home&lt;/name&gt;
          &lt;value&gt;${project.basedir}/target/wildfly-8.1.0.Final&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;module.path&lt;/name&gt;
          &lt;value&gt;${project.basedir}/target/wildfly-8.1.0.Final/modules&lt;/value&gt;
      &lt;/property&gt;
  &lt;/systemProperties&gt; &lt;/configuration&gt; &lt;/plugin&gt;
  </code></pre>
  
  <h3>Now, when I'm trying to run the test, an error is shown:</h3>
  
  <pre><code>[ERROR]
  /home/me/playground/arquillian-tutorial/src/test/java/org/arquillian/example/ATest.java:[3,19]
  error: package javax.inject does not exist
  </code></pre>
  
  <p>... i.e. the classes are not found.</p>
  
  <p>An excerpt from my pom file:</p>
  
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.3.2&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.6&lt;/source&gt;
                  &lt;target&gt;1.6&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.17&lt;/version&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  &lt;dependencyManagement&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.jboss.arquillian&lt;/groupId&gt;
              &lt;version&gt;1.1.5.Final&lt;/version&gt;
              &lt;artifactId&gt;arquillian-bom&lt;/artifactId&gt;
              &lt;scope&gt;import&lt;/scope&gt;
              &lt;type&gt;pom&lt;/type&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.8.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.arquillian.junit&lt;/groupId&gt;
          &lt;artifactId&gt;arquillian-junit-container&lt;/artifactId&gt;
          &lt;!-- &lt;version&gt;1.1.5.Final&lt;/version&gt; --&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
      &lt;profile&gt;
          &lt;id&gt;arquillian-wildfly8-managed&lt;/id&gt;
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.jboss.spec&lt;/groupId&gt;
                  &lt;artifactId&gt;jboss-javaee-6.0&lt;/artifactId&gt;
                  &lt;version&gt;3.0.1.Final&lt;/version&gt;
                  &lt;type&gt;pom&lt;/type&gt;
                  &lt;scope&gt;test&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;!-- Required by jboss-javaee-6.0:3.0.2.Final (https://issues.jboss.org/browse/JBBUILD-708) --&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;xalan&lt;/groupId&gt;
                  &lt;artifactId&gt;xalan&lt;/artifactId&gt;
                  &lt;version&gt;2.7.1&lt;/version&gt;
                  &lt;scope&gt;test&lt;/scope&gt;
              &lt;/dependency&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.wildfly&lt;/groupId&gt;
                  &lt;artifactId&gt;wildfly-arquillian-container-managed&lt;/artifactId&gt;
                  &lt;version&gt;8.1.0.Final&lt;/version&gt;
                  &lt;scope&gt;test&lt;/scope&gt;
              &lt;/dependency&gt;
          &lt;/dependencies&gt;
          &lt;build&gt;
              &lt;pluginManagement&gt;
                  &lt;plugins&gt;
                      &lt;plugin&gt;
                          &lt;!-- You need the maven dependency plugin to download locally a zip 
                              with the server, unless you provide your own, it will download under the 
                              /target directory --&gt;
                          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                          &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
                          &lt;version&gt;2.8&lt;/version&gt;
                          &lt;executions&gt;
                              &lt;execution&gt;
                                  &lt;id&gt;unpack&lt;/id&gt;
                                  &lt;phase&gt;process-test-classes&lt;/phase&gt;
                                  &lt;goals&gt;
                                      &lt;goal&gt;unpack&lt;/goal&gt;
                                  &lt;/goals&gt;
                                  &lt;configuration&gt;
                                      &lt;artifactItems&gt;
                                          &lt;artifactItem&gt;
                                              &lt;groupId&gt;org.wildfly&lt;/groupId&gt;
                                              &lt;artifactId&gt;wildfly-dist&lt;/artifactId&gt;
                                              &lt;version&gt;8.1.0.Final&lt;/version&gt;
                                              &lt;type&gt;zip&lt;/type&gt;
                                              &lt;overWrite&gt;false&lt;/overWrite&gt;
                                              &lt;outputDirectory&gt;target&lt;/outputDirectory&gt;
                                          &lt;/artifactItem&gt;
                                      &lt;/artifactItems&gt;
                                  &lt;/configuration&gt;
                              &lt;/execution&gt;
                          &lt;/executions&gt;
                      &lt;/plugin&gt;
                  &lt;/plugins&gt;
              &lt;/pluginManagement&gt;
          &lt;/build&gt;
      &lt;/profile&gt;
  </code></pre>
  
  <p>I am confused. I am unable to find a simple setup to run test cases via Arquillian/Wildfly in a proper way. Do you have any ideas, hints or links?</p>