title: java jvax inject fail with nullpoint NullPointerException
body: <p>I try to use dependency injections in my project. I make something wrong, but i can not see my failure.</p>
  
  <p>My project setup:</p>
  
  <pre><code>Maven main project
  |-- maven module "model"
    |-- org.inject.test.model
      |-- Address.java
      |-- User.java
    |-- org.inject.test.model.manger
      |-- UserManager.java
  |-- maven module "core"
    |-- org.inject.test.core
      |-- MyMain.java
   |-- org.inject.test.core.managerImpl
     |-- UserManagerImpl.java
  </code></pre>
  
  <p>Address.class:</p>
  
  <pre><code>package org.inject.test.model;
  
  public class Address {
  
      private String street;
  
      public String getStreet() {
          return street;
      }
  
      public void setStreet(String street) {
          this.street = street;
      }
  }
  </code></pre>
  
  <p>User.class:</p>
  
  <pre><code>package org.inject.test.model;
  
  import javax.inject.Inject;
  import javax.inject.Named;
  
  import org.inject.test.model.manager.UserManager;
  
  @Named
  public class User {
  
      private String name;
      private Address address;
  
      @Inject
      private UserManager usermanager;
  
      public User (String name) {
          this.name = name;
          address = null;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public Address getAddress() {
          if (address == null) {
              address = usermanager.getAddress();
          }
          return address;
      }
  
      public void setAddress(Address address) {
          this.address = address;
      }
  }
  </code></pre>
  
  <p>User Manager Interface:</p>
  
  <pre><code>package org.inject.test.model.manager;
  
  import org.inject.test.model.Address;
  
  public interface UserManager {
  
      public Address getAddress ();
  }
  </code></pre>
  
  <p>User Manager Impl:</p>
  
  <pre><code>package org.inject.test.core.managerImpl;
  
  import javax.inject.Named;
  
  import org.inject.test.model.Address;
  import org.inject.test.model.manager.UserManager;
  
  @Named
  public class UserManagerImpl implements UserManager {
  
      public Address getAddress() {
          // Do the DB stuff here (DB.getAddress...)
          Address address = new Address();
          address.setStreet("My test street");
  
          return address;
      }
  }
  </code></pre>
  
  <p>MyMain Class:</p>
  
  <pre><code>package org.inject.test.core;
  
  import javax.inject.Inject;
  
  import org.inject.test.model.Address;
  import org.inject.test.model.User;
  import org.inject.test.model.manager.UserManager;
  import org.jboss.weld.environment.se.Weld;
  import org.jboss.weld.environment.se.WeldContainer;
  
  public class MyMain {
  
      @Inject
      UserManager usermanager;
  
      public static void main(String[] args) {
          // run everything in a weld container (we need someone who manages our injects)
          Weld weld = new Weld();
          WeldContainer weldContainer = weld.initialize();
          MyMain mymain = weldContainer.instance().select(MyMain.class).get();
  
          mymain.printUser();
      }
  
      private void printUser() {
          // Working inject
          System.out.println("Working inject: " + usermanager.getAddress().getStreet() + "\n");
  
          // Not working inject in the user class
          User myuser = new User("nobody");
          System.out.println("Username: " + myuser.getName() + "\n");
  
          try {
              Address address = myuser.getAddress();
              String streetname = address.getStreet();
              System.out.println("User Street: " + streetname + "\n");
          } catch (Exception e) {
              System.out.println(e + "\n");
          }
  
      }
  
  }
  </code></pre>
  
  <p>This my lets say small test project.
  My Problem here is that the <code>@Inject</code> in the User class does not work.
  In the <code>getAddress()</code> function I get an <code>java.lang.NullPointerException</code>.
  But the <code>@Inject</code> in the <code>MyMain</code> class works.</p>
  
  <p>I have uploaded the whole maven project:
  <a href="http://www.file-upload.net/download-9979514/inject_test.zip.html" rel="nofollow">http://www.file-upload.net/download-9979514/inject_test.zip.html</a></p>
  
  <p>Run it with <code>mvn clean verify</code></p>
  
  <p>Output is something like this:</p>
  
  <pre><code>[...]
  556 [org.inject.test.core.MyMain.main()] WARN org.jboss.weld.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
  556 [org.inject.test.core.MyMain.main()] WARN org.jboss.weld.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled
  Working inject: My test street
  
  Username: nobody
  
  java.lang.NullPointerException
  
  [INFO] ------------------------------------------------------------------------
  [INFO] Reactor Summary:
  [INFO] 
  [INFO] test .............................................. SUCCESS [0.739s]
  [INFO] test-model ........................................ SUCCESS [2.539s]
  [INFO] test-core ......................................... SUCCESS [1.851s]
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  </code></pre>