title: Error injecting constructor, java.lang.NullPointerException at controllers
body: <p>I'm getting the following error message:</p>
  
  <blockquote>
    <p>ProvisionException: Unable to provision, see the following errors:</p>
    
    <p>1) Error injecting constructor, java.lang.NullPointerException   at
    controllers.ProductsController.(ProductsController.java:20)<br>
    while locating controllers.ProductsController
        for the 4th parameter of router.Routes.(Routes.scala:34)   while locating router.Routes   while locating
    play.api.inject.RoutesProvider   while locating
    play.api.routing.Router
        for the 1st parameter of play.api.http.JavaCompatibleHttpRequestHandler.(HttpRequestHandler.scala:222)
    while locating play.api.http.JavaCompatibleHttpRequestHandler   while
    locating play.api.http.HttpRequestHandler
        for the 6th parameter of play.api.DefaultApplication.(Application.scala:236)   at
    play.api.DefaultApplication.class(Application.scala:235)   while
    locating play.api.DefaultApplication   while locating
    play.api.Application</p>
    
    <p>1 error</p>
  </blockquote>
  
  <p>Here's the Stack Trace:</p>
  
  <pre><code>com.google.inject.ProvisionException: Unable to provision, see the following errors:
  
  1) Error injecting constructor, java.lang.NullPointerException
    at controllers.ProductsController.&lt;init&gt;(ProductsController.java:20)
    while locating controllers.ProductsController
      for the 4th parameter of router.Routes.&lt;init&gt;(Routes.scala:34)
    while locating router.Routes
    while locating play.api.inject.RoutesProvider
    while locating play.api.routing.Router
      for the 1st parameter of play.api.http.JavaCompatibleHttpRequestHandler.&lt;init&gt;(HttpRequestHandler.scala:222)
    while locating play.api.http.JavaCompatibleHttpRequestHandler
    while locating play.api.http.HttpRequestHandler
      for the 6th parameter of play.api.DefaultApplication.&lt;init&gt;(Application.scala:236)
    at play.api.DefaultApplication.class(Application.scala:235)
    while locating play.api.DefaultApplication
    while locating play.api.Application
  
  1 error
       com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1028)
       com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1054)
       play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:409)
       play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:404)
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>package controllers;
  
  import java.util.List;
  
  import javax.inject.Inject;
  import javax.inject.Provider;
  import javax.inject.Singleton;
  
  import play.mvc.Controller;
  import play.mvc.Result;
  
  import play.data.Form;
  import play.data.FormFactory;
  
  import views.html.products.details;
  import views.html.products.list;
  
  import models.Product;
  
  public class ProductsController extends Controller {
  
      @Inject FormFactory formFactory;
      private Form&lt;Product&gt; productForm = formFactory.form(Product.class);
  
      public Result list() {
          List&lt;Product&gt; products = Product.findAll();
          return ok(list.render(products));
      }
  
      public Result newProduct() {
          return ok(details.render(productForm));
      }
  
      public Result details(String ean) {
          return TODO;
      }
  
      public Result save() {
          return TODO;
      }
  }
  </code></pre>
  
  <p>I'm not really sure what should I do. I've been searching all over the place and couldn't find anything useful. Thoughts?</p>