title: Guice injection null pointer
body: <p>We try to refactoring a project with Guice. The idea is to bind all the <em>Language</em> interface to a concreate object like <em>French</em> or <em>Polish</em>.</p>
  
  <p>We have a module for binding:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class StandardModule extends AbstractModule {
  
      @Override
      protected void configure() {
  
         bind(Language.class).to(Polish.class);
  
      }
   }
  </code></pre>
  
  <p>And a classe (AboutDialog.java) that use this injected object :</p>
  
  <pre class="lang-java prettyprint-override"><code>@Inject Language language;
  
  public AboutDialog(JFrame parent) {
      super(parent, "", true);
      this.language=language;
      this.setTitle(language.getLanguageInUse().getString("AboutDialog.title"));
      this.parent = parent;
      try {
          jbInit();
      } catch (Exception e) {
          e.printStackTrace();
      }
      pack();
  }
  </code></pre>
  
  <p>And we have as result:</p>
  
  <pre class="lang-java prettyprint-override"><code>java.lang.NullPointerException at net.sf.jmoney.gui.AboutDialog.&lt;init&gt;(AboutDialog.java:67)
  </code></pre>
  
  <p>Line 67 is:</p>
  
  <pre class="lang-java prettyprint-override"><code>this.setTitle(language.getLanguageInUse().getString("AboutDialog.title"));
  </code></pre>
  
  <p>Our interface is:</p>
  
  <pre class="lang-java prettyprint-override"><code>public interface Language {
  
      public ResourceBundle getLanguageInUse();
  }
  </code></pre>
  
  <p>And the Polish class is:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Polish implements Language {
  
      private ResourceBundle languageInUse;
  
      public Polish() {
          languageInUse = ResourceBundle.getBundle(Constants.LANGUAGE_PL);
      }
  
      public ResourceBundle getLanguageInUse() {
          return languageInUse;
      }
  
  
  }
  </code></pre>
  
  <p>We are lost... </p>