title: Unit Test: @Inject not injecting service
body: <p>here is my entity</p>
  
  <pre><code>@Entity
  public class User {
      @Id
      private String id;
      private String externalUserId;
      private String email;
      private String clientId;
      private String clientSecret;
      private boolean active;
  
      public User(@Nonnull final String externalUserId, @Nonnull final String email,
                  @Nonnull final String clientId, @Nonnull final String clientSecret, final boolean active) {
          id = UUID.randomUUID().toString();
          this.externalUserId = externalUserId;
          this.email = email;
          this.clientId = clientId;
          this.clientSecret = clientSecret;
          this.active = active;
      }
  }
  </code></pre>
  
  <p>and a <code>UserService</code>  </p>
  
  <pre><code>import javax.annotation.Nonnull;
  import javax.ejb.Stateless;
  import javax.persistence.EntityManager;
  import javax.persistence.PersistenceUnit;
  
  @Stateless
  public class UserService {
      @PersistenceUnit
      private EntityManager entityManager;
  
  
      @Nonnull
      public User createUser(@Nonnull final User user) {
          entityManager.persist(user);
          return user;
      }
  }
  </code></pre>
  
  <p>I also have <code>DBConfig</code> as  </p>
  
  <pre><code>import javax.annotation.sql.DataSourceDefinition;
  import javax.ejb.Stateless;
  
  @DataSourceDefinition(
          name = "java:app/oauth/testDB",
          className = "org.h2.jdbcx.JdbcDataSource",
          url = "jdbc:h2:mem:test"
  )
  @Stateless
  public class DBConfig {
  }
  </code></pre>
  
  <p><code>test/src/main/resources/persistence.xml</code> as  </p>
  
  <pre><code>&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
               version="2.0"&gt;
      &lt;persistence-unit name="testDB" transaction-type="RESOURCE_LOCAL"&gt;
          &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
          &lt;class&gt;com.self.oauth.persistence.entities.User&lt;/class&gt;
      &lt;/persistence-unit&gt;
  &lt;/persistence&gt;  
  </code></pre>
  
  <p>My test looks like  </p>
  
  <pre><code>public class UserTest {
  
      @Inject
      private UserService userService;
  
      @Test
      public void testUser() {
          final User user = new User(UUID.randomUUID().toString(), "test@test.com", "clientId", "clientSecret", true);
          userService.createUser(user);
          assertTrue(true);
      }
  }  
  </code></pre>
  
  <p>and I get <code>NullPointeException</code> on <code>userService</code></p>
  
  <p>What am I missing?</p>