title: Arquillian fails to inject dependencies after the first test class
body: <p>I have a slightly weird problem.
  I'm currently using Arquillian (1.1.0.Final) together with Embedded GlassFish (3.1.2.2).
  I used following <a href="http://arquillian.org/guides/testing_java_persistence/" rel="nofollow">guide</a> to setup my little test project.
  Everything worked fine with the integrated Derby database.
  My real application uses PostgreSQL as a database, so I configured my GlassFish resources as follows:</p>
  
  <pre><code>    &lt;!-- See http://jdbc.postgresql.org/documentation/91/ds-cpds.html --&gt;
      &lt;jdbc-connection-pool name="MyPostgresqlPool"
                            res-type="javax.sql.DataSource"
                            datasource-classname="org.postgresql.ds.PGSimpleDataSource"
                            is-isolation-level-guaranteed="false"&gt;
  
          &lt;property name="user" value="..." /&gt;
          &lt;property name="databaseName" value="..." /&gt;
          &lt;property name="password" value="..." /&gt;
          &lt;property name="serverName" value="..." /&gt;
          &lt;property name="portNumber" value="..." /&gt;
  
      &lt;/jdbc-connection-pool&gt;
  </code></pre>
  
  <p>And I access the persistence context and the user transaction as described in above guide:</p>
  
  <pre><code>@RunWith(Arquillian.class)
  public class AddressModuleTest extends BaseTest {
      @PersistenceContext
      protected EntityManager em;
  
      @Inject
      protected UserTransaction utx;
  
      @Before
      public void setUp() throws Exception {
          utx.begin();
          em.joinTransaction();
      }
  
      @After
      public void tearDown() throws Exception {
          utx.rollback();
      }
  
   [ ... snip ...]
  }
  </code></pre>
  
  <p>If I run my test class (AddressModuleTest, please note that "BaseTest" has a static method annotated with @Deployment for Arquillian) everything is fine and I can read my data from the PostgreSQL database.</p>
  
  <p>Unfortunately, If I create a second test class it won't work:</p>
  
  <pre><code>@RunWith(Arquillian.class)
  public class CommunicationModuleTest extends BaseTest {
      @PersistenceContext
      protected EntityManager em;
  
      @Inject
      protected UserTransaction utx;
  
      @Before
      public void setUp() throws Exception {
          utx.begin();
          em.joinTransaction();
      }
  
      @After
      public void tearDown() throws Exception {
          utx.rollback();
      }
  
      [ ... snip ... ]
  }
  </code></pre>
  
  <p>Maven (respectively surefire) gives me the following error:</p>
  
  <pre><code>Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.758 sec &lt;&lt;&lt; FAILURE!
  loadMessageDAO(package.CommunicationModuleTest)  Time elapsed: 0.027 sec  &lt;&lt;&lt; ERROR!
  java.lang.RuntimeException: Could not inject members
      at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:135)
      at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.enrich(CDIInjectionEnricher.java:78)
      at org.jboss.arquillian.test.impl.TestInstanceEnricher.enrich(TestInstanceEnricher.java:52)
      at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  [ ... snip ... ]
  </code></pre>
  
  <p>.. with the following root exception:</p>
  
  <pre><code>Caused by: org.jboss.weld.exceptions.IllegalArgumentException: WELD-001324 Argument bean must not be null
      at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:678)
      at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:136)
      at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:686)
      at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:695)
      at org.jboss.weld.manager.SimpleInjectionTarget$1.proceed(SimpleInjectionTarget.java:106)
      at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:134)
      at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46)
      at org.jboss.weld.manager.SimpleInjectionTarget.inject(SimpleInjectionTarget.java:102)
      at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectNonContextualInstance(CDIInjectionEnricher.java:145)
      at org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:125)
      ... 79 more
  </code></pre>
  
  <p>I went back to the guide and tried to reproduce my issue with their code - with no sucess (i.e. they are not affected by my problem). Therefore I assume that either my UserTransaction handling is wrong or it is an issue with my PostgreSQL configuration.
  I tried different datasources, namely</p>
  
  <ul>
  <li><code>org.postgresql.ds.PGSimpleDataSource</code></li>
  <li><code>org.postgresql.ds.PGPoolingDataSource</code></li>
  </ul>
  
  <p>As well as <code>javax.xa.XADataSource</code> together with <code>org.postgresql.xa.PGXADataSource</code> with no success.</p>
  
  <p>Does somebody have a clue what's wrong? I have to admit that I'm (very) inexperience with different DataSources as well as Transaction Management.</p>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>It looks as if the issue is independent of PostgreSQL as it happens on MySQL (MariaDB) as well. The stacktrace is the same, so I assume the issue lies within my Transaction Management..</p>
  
  <hr>
  
  <p>Kind regards and many thanks for your help</p>
  
  <p>stupidSheep</p>