title: load on startup and Jersey
body: <p>Possibly duplicate of <a href="https://stackoverflow.com/questions/9787332/servlet-not-loading-on-startup">Servlet not loading on startup</a>, however Im not allowed yet to comment, so I have to start a new question for this...</p>
  
  <p>Same setting, having a servlet using Jersey and Tomcat, using load-on-startup for loading the container.
  However, due to the thread mentioned above, I understand that this only load the Jersey container but not the classes I setup for the servlet. </p>
  
  <p>So, related to what is implied in the answer of the thread above, how is it done that not only the contained is loaded at startup but also my classes which are annotated with @Path (which will e.g. load data from a DB in memory).</p>
  
  <pre><code>@Singleton
  @Path( "156846986" )
  public class SearchEngine {
  
      @Inject
      private DatabaseService dbService;
  
      @Inject
      private PatriciaTrieEngine trieEngine;
  }
  </code></pre>
  
  <p>and for example:</p>
  
  <pre><code>@Singleton
  @Path( "3455470640" )
  public class PatriciaTrieEngine {
  
  @Inject
  DatabaseService dbService;
  private PatriciaTrie&lt; Object &gt; patriciaTrie;
  
  @PostConstruct
  public void init( ) throws SQLException {
  
      ...some code initializing the trie by loading data from a database u using dbService
  }
  </code></pre>
  
  <p>}</p>
  
  <p>finally some classes like <code>SearchService</code> have the endpoints for requests:</p>
  
  <pre><code>@Path( "/search" )
  @Produces( "application/json" )
  public class SearchService {
  
      @Inject
      private DatabaseService dbService;
      @Inject
      private SearchEngine    engine;
  
      @GET
      @Path( "/candidates" )
      public Response getCandidates(@QueryParam( "query" ) final String input) throws UnsupportedEncodingException {
  
      use Patricia trie via SearchEngine in order to find candidates for given query
  
      return Response.ok().entity( candidates ).build();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Ultimately it is the PatriciaTrie which should be loaded at startup as it takes several minutes to load the data into the trie.</p>