title: Play framework: Unexpected exception after or during DB evolution
body: <p>Suddenly I got this strange error right after I confirm DB evolution for my Play-Framework project:</p>
  
  <pre><code>Unexpected exception
  NullPointerException: null
  No source available, here is the exception stack trace:
  -&gt;java.lang.NullPointerException: 
       com.avaje.ebean.Ebean.save(Ebean.java:533)
       Global.onStart(Global.java:18)
       play.core.j.JavaGlobalSettingsAdapter.onStart(JavaGlobalSettingsAdapter.scala:22)
       play.api.GlobalPlugin.onStart(GlobalSettings.scala:220)
       play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
       play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
       scala.collection.immutable.List.foreach(List.scala:383)
       play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:91)
       play.api.Play$$anonfun$start$1.apply(Play.scala:91)
       play.api.Play$$anonfun$start$1.apply(Play.scala:91)
       play.utils.Threads$.withContextClassLoader(Threads.scala:21)
       play.api.Play$.start(Play.scala:90)
       play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:157)
       play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:130)
       scala.Option.map(Option.scala:145)
       play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:130)
       play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:128)
       scala.util.Success.flatMap(Try.scala:230)
       play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:128)
       play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:120)
       scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
       scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
       scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1361)
       scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
       scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
       scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
       scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
  </code></pre>
  
  <p>I don't know how to debug this error, there is nothing that points to any of my files.
  Here is output I get in consoel:</p>
  
  <pre><code>! @6kekc98dk - Internal server error, for (GET) [/] -&gt;
  
  play.api.db.evolutions.InvalidDatabaseRevision: Database 'default' needs evolution![An SQL script need to be run on your database.]
      at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1$$anonfun$apply$1.apply$mcV$sp(Evolutions.scala:510) ~[play-jdbc_2.11-2.3.6.jar:2.3.6]
      at play.api.db.evolutions.EvolutionsPlugin.withLock(Evolutions.scala:531) ~[play-jdbc_2.11-2.3.6.jar:2.3.6]
      at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.scala:485) ~[play-jdbc_2.11-2.3.6.jar:2.3.6]
      at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.scala:483) ~[play-jdbc_2.11-2.3.6.jar:2.3.6]
      at scala.collection.immutable.List.foreach(List.scala:383) ~[scala-library-2.11.1.jar:na]
  [warn] play - Error stopping plugin
  java.lang.NullPointerException: null
      at play.libs.ws.ning.NingWSPlugin.onStop(NingWSPlugin.java:31) ~[play-java-ws_2.11-2.3.6.jar:2.3.6]
      at play.api.Play$$anonfun$stop$1$$anonfun$apply$1$$anonfun$apply$mcV$sp$2.apply(Play.scala:108) [play_2.11-2.3.6.jar:2.3.6]
      at play.api.Play$$anonfun$stop$1$$anonfun$apply$1$$anonfun$apply$mcV$sp$2.apply(Play.scala:107) [play_2.11-2.3.6.jar:2.3.6]
      at scala.collection.immutable.List.foreach(List.scala:383) [scala-library-2.11.1.jar:na]
      at play.api.Play$$anonfun$stop$1$$anonfun$apply$1.apply$mcV$sp(Play.scala:107) [play_2.11-2.3.6.jar:2.3.6]
  [info] play - database [default] connected at jdbc:h2:mem:play
  [error] application - 
  
  ! @6kekd052e - Internal server error, for (GET) [/] -&gt;
  
  play.api.UnexpectedException: Unexpected exception[NullPointerException: null]
      at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:166) ~[play_2.11-2.3.6.jar:2.3.6]
      at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:130) ~[play_2.11-2.3.6.jar:2.3.6]
      at scala.Option.map(Option.scala:145) ~[scala-library-2.11.1.jar:na]
      at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:130) ~[play_2.11-2.3.6.jar:2.3.6]
      at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:128) ~[play_2.11-2.3.6.jar:2.3.6]
  Caused by: java.lang.NullPointerException: null
      at com.avaje.ebean.Ebean.save(Ebean.java:533) ~[avaje-ebeanorm-3.3.4.jar:na]
      at Global.onStart(Global.java:18) ~[na:na]
      at play.core.j.JavaGlobalSettingsAdapter.onStart(JavaGlobalSettingsAdapter.scala:22) ~[play_2.11-2.3.6.jar:2.3.6]
      at play.api.GlobalPlugin.onStart(GlobalSettings.scala:220) ~[play_2.11-2.3.6.jar:2.3.6]
      at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91) ~[play_2.11-2.3.6.jar:2.3.6]
  </code></pre>
  
  <p>Global.java : </p>
  
  <pre><code>import com.avaje.ebean.Ebean;
  import models.MediumModel;
  import models.MobileAppModule;
  import models.LandingModule;
  import play.Application;
  import play.GlobalSettings;
  import play.libs.Yaml;
  
  import java.util.List;
  
  /**
   * Created by usr on 11/11/14.
   */
  public class Global extends GlobalSettings{
      @Override
      public void onStart(Application app) {
          if (MediumModel.find.findRowCount() == 0) {
              Ebean.save((List) Yaml.load("initial-medium-data.yml"));
          }
          if (MobileAppModule.find.findRowCount() == 0) {
              Ebean.save((List) Yaml.load("initial-app-data.yml"));
          }
          if (LandingModule.find.findRowCount() == 0) {
              Ebean.save((List) Yaml.load("initial-frontend-data.yml"));
          }
  
      }
  }
  </code></pre>