title: Play 2.5.12 Java - Missing HttpContext when replacing deprecated GlobalSettings.OnStart
body: <p>I'm trying to migrate from Play 2.3 to 2.5 but I have an issue on replacing the GlobalSettings.OnStart method.
  In my old Global class that was extending GlobalSettings, in the onStartMethod I was initialising the Global Config and reading basic things from the DB.
  I have created a new class and I m moving the code from the onStart method to the constructor of this one as mentioned in the doc.</p>
  <p><a href="https://www.playframework.com/documentation/2.5.x/GlobalSettings" rel="nofollow noreferrer">https://www.playframework.com/documentation/2.5.x/GlobalSettings</a>
  <a href="https://www.playframework.com/documentation/2.4.x/PluginsToModules" rel="nofollow noreferrer">https://www.playframework.com/documentation/2.4.x/PluginsToModules</a></p>
  <p>I'm doing the binding as eagerSingleton from an AbstractModule. The class is correctly started but I keep getting the error:</p>
  <blockquote>
  <p>GlobalBootstrapModule.configure:20 - Binding</p>
  <p>OnStartConfig.:35 - Global...on start</p>
  <p>Caused by: java.lang.RuntimeException: No EntityManager bound to this thread. Try wrapping this call in JPAApi.withTransaction, or ensure that the HTTP context is setup on this thread.</p>
  </blockquote>
  <p>This is my code:</p>
  <p>New class to replace onStart</p>
  <pre><code>public class OnStartConfig implements StartConfigInterface{
  
  private final JPAApi jpaApi;
  
  @Inject
  public OnStartConfig(Application application, JPAApi jpa){
     this.jpaApi = jpa;
     Logger.debug(&quot;Global...on start&quot;);
  
     jpaApi.withTransaction( ()-&gt; {
          GlobalConfiguration.aggregationCriteria = AggregationCriterion.getAll();
      });
  }
  </code></pre>
  <p>The interface I'm extending is just an empty placeholder.</p>
  <p>AbstractModule used for the binding:</p>
  <pre><code>public class GlobalBootstrapModule extends AbstractModule {
  
  @Override
  protected void configure() {
  
  Logger.debug(&quot;Binding&quot;);
  bind(StartConfigInterface.class).to(OnStartConfig.class).asEagerSingleton();
  
      }
  }
  </code></pre>
  <p>And I have enabled the module in the application.conf file:</p>
  <pre><code>play {
     modules {
     enabled += modules.GlobalBootstrapModule
     }
  }
  </code></pre>
  <p>I suppose the problem is due to the lack of HttpContext. Where can I grab it from during the initialisation?
  Any help would be hugely appreciated</p>