title: CreationException: Unable to create injector error in Play 2.5.18 in replacement for GlobalSettings Java code using com.google.inject.AbstractModule
body: <p>I am upgrading my Play application from 2.5.12 to 2.5.18 and when I start up the application (using <code>sbt</code>), I am receiving this error:</p>
  
  <p>CreationException: Unable to create injector, see the following errors:</p>
  
  <pre><code>1) Error injecting constructor, java.lang.NullPointerException
    at modules.OnStart.&lt;init&gt;(OnStart.java:15)
    at modules.Global.configure(Global.java:9) (via modules: com.google.inject.util.Modules$OverrideModule -&gt; modules.Global)
    while locating modules.OnStart
  
  1 error
  </code></pre>
  
  <p>The rest of the error is:</p>
  
  <pre><code>No source available, here is the exception stack trace:
  -&gt;com.google.inject.CreationException: Unable to create injector, see the following errors:
  
  1) Error injecting constructor, java.lang.NullPointerException
    at modules.OnStart.&lt;init&gt;(OnStart.java:15)
    at modules.Global.configure(Global.java:9) (via modules: com.google.inject.util.Modules$OverrideModule -&gt; modules.Global)
    while locating modules.OnStart
  
  1 error
       com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:470)
       com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:184)
       com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
       com.google.inject.Guice.createInjector(Guice.java:99)
       com.google.inject.Guice.createInjector(Guice.java:84)
       play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
       play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:137)
       play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
       play.core.server.DevServerStart$$anon$1.$anonfun$get$6(DevServerStart.scala:171)
       play.utils.Threads$.withContextClassLoader(Threads.scala:21)
       play.core.server.DevServerStart$$anon$1.$anonfun$get$3(DevServerStart.scala:168)
       scala.Option.map(Option.scala:146)
       play.core.server.DevServerStart$$anon$1.$anonfun$get$2(DevServerStart.scala:133)
       scala.util.Success.flatMap(Try.scala:247)
       play.core.server.DevServerStart$$anon$1.$anonfun$get$1(DevServerStart.scala:131)
       scala.concurrent.Future$.$anonfun$apply$1(Future.scala:655)
       scala.util.Success.$anonfun$map$1(Try.scala:251)
       scala.util.Success.map(Try.scala:209)
       scala.concurrent.Future.$anonfun$map$1(Future.scala:289)
       scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:29)
       scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:29)
       scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
       scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:140)
       java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
       java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
       java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
       java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
  </code></pre>
  
  <p>I created new modules to replace the deprecated <code>GlobalSettings</code> based on this post:</p>
  
  <p><a href="https://www.playframework.com/documentation/2.5.x/GlobalSettings" rel="noreferrer">https://www.playframework.com/documentation/2.5.x/GlobalSettings</a></p>
  
  <p>Here are the classes mentioned in the error:</p>
  
  <p>Global.java</p>
  
  <pre><code>package modules;
  
  import com.google.inject.AbstractModule;
  
  public class Global extends AbstractModule {
  
      @Override
      public void configure() {
          bind(OnStart.class).asEagerSingleton();
          bind(OnStop.class).asEagerSingleton();
      }
  
  }
  </code></pre>
  
  <p>OnStart.java</p>
  
  <pre><code>package modules;
  
  import javax.inject.Inject;
  import javax.inject.Singleton;
  
  import jobs.JobControl;
  import com.typesafe.config.Config;
  import play.Logger;
  
  @Singleton
  public class OnStart {
  
      @Inject
      public OnStart(Config config) {
          Logger.debug("Application started...");     
          // Turn on scheduler?
          String schedulerEnabled;
          String dueDateRun;
          schedulerEnabled = config.getString("scheduler.enabled");
          dueDateRun = config.getString("duedate.run.flag");
          if (schedulerEnabled.equals("true")) {
              //JobControl.cleanupTables();
              //JobControl.emptyRecycleBin();
              if (dueDateRun.equals("on")) {
                  JobControl.dueDateNotifications();
              }
          }
      }
  }
  </code></pre>
  
  <p>I am not sure what to do to fix this.</p>