title: playframework 2.4 GlobalSettings onStart Deprecated
body: <p>I am migrating my app from play 2.3 to 2.4.</p>
  
  <p>In my 2.3 app in my GlobalSettings, I had to access the database using slick to create a postgres database function.</p>
  
  <p>Since GlobalSettings is deprecated in 2.4, the alternative is to use Eager Bindings:</p>
  
  <p><a href="https://www.playframework.com/documentation/2.4.x/ScalaDependencyInjection#Eager-bindings" rel="nofollow">https://www.playframework.com/documentation/2.4.x/ScalaDependencyInjection#Eager-bindings</a></p>
  
  <p>like this:</p>
  
  <pre><code>class MyModule extends AbstractModule {
    def configure() = {
      db.withSession { implicit ss =&gt;
        StaticQuery.update("""CREATE OR REPLACE FUNCTION ... """).execute
      }
    }
  }
  </code></pre>
  
  <p>But this gives me the error:</p>
  
  <pre><code>java.lang.ExceptionInInitializerError: 
       core.includes$.&lt;init&gt;(includes.scala:14)
       core.includes$.&lt;clinit&gt;(includes.scala)
       Application$$anonfun$configure$1.apply(Application.scala:17)
       Application$$anonfun$configure$1.apply(Application.scala:15)
       scala.slick.backend.DatabaseComponent$DatabaseDef$class.withSession(DatabaseComponent.scala:34)
       scala.slick.jdbc.JdbcBackend$DatabaseFactoryDef$$anon$4.withSession(JdbcBackend.scala:61)
       modules.jdbc.Database$$anonfun$withSession$1.apply(Database.scala:14)
       modules.jdbc.Database$$anonfun$withSession$1.apply(Database.scala:14)
       Application.configure(Application.scala:15)
       com.google.inject.AbstractModule.configure(AbstractModule.java:62)
       com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
       com.google.inject.spi.Elements.getElements(Elements.java:110)
       com.google.inject.util.Modules$OverrideModule.configure(Modules.java:177)
       com.google.inject.AbstractModule.configure(AbstractModule.java:62)
       com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
       com.google.inject.spi.Elements.getElements(Elements.java:110)
       com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:138)
       com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
       com.google.inject.Guice.createInjector(Guice.java:96)
       com.google.inject.Guice.createInjector(Guice.java:73)
       com.google.inject.Guice.createInjector(Guice.java:62)
       play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126)
       play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93)
       play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
  </code></pre>
  
  <p>Does anyone have a clue on how I can fix this? Thanks.</p>