title: Dropwizard HK2 injection
body: <p>im pretty new in working with dropwizard. Currently I'm trying to implement the HK2 dependency injection. That works pretty fine inside a resource but it doesn't work outside of a resource. Here is what I'm doing: </p>
  
  <pre><code>Client client = new JerseyClientBuilder(environment).using(configuration.getJerseyClientConfiguration()).build("contentmoduleservice");
  
      //DAOs
      ContentModuleDAO contentModuleDAO = new ContentModuleDAO(hibernate.getSessionFactory());
      ModuleServedDAO moduleServedDAO = new ModuleServedDAO(hibernate.getSessionFactory());
  
      //Manager
      ContentModuleManager moduleManager = new ContentModuleManager();
      EntityTagManager eTagManager = new EntityTagManager();
      ProposalManager proposalManager = new ProposalManager(client, configuration);
  
      environment.jersey().register(new AbstractBinder() {
          @Override
          protected void configure() {
              bind(eTagManager).to(EntityTagManager.class);
              bind(contentModuleDAO).to(ContentModuleDAO.class);
              bind(moduleServedDAO).to(ModuleServedDAO.class);
              bind(proposalManager).to(ProposalManager.class);
              bind(moduleManager).to(ContentModuleManager.class);
          }
      });
  </code></pre>
  
  <p>I create Instance of the classes I want to be injectible and bind them.</p>
  
  <p>Inside my resource the injection works:</p>
  
  <pre><code>@Api
  @Path("/api/contentmodule")
  public class ContentModuleResource {
  
      static final Logger LOG = LoggerFactory.getLogger(ContentModuleResource.class);
      static final int MAX_PROPOSALS_PER_MODULE = 10;
  
      @Inject
      private ContentModuleDAO contentModuleDAO;
  
      @Inject
      private EntityTagManager eTagManager;
  
      @Inject
      private ProposalManager proposalManager;
  
      @Inject
      private ContentModuleManager contentModuleManager;
  </code></pre>
  
  <p>All these variables are filled with an Instance of the right class.</p>
  
  <p>The problem is: The ContentModuleManager should also get some of these classes via injection:</p>
  
  <pre><code>public class ContentModuleManager {
  
  @Inject
  private ContentModuleDAO contentModuleDAO;
  
  @Inject
  private ProposalManager proposalManager;
  
  @Inject
  private ModuleServedDAO moduleServedDAO;
  </code></pre>
  
  <p>But those are null. Can somebody explain a dropwizard noob why this happens and how I can fix this? :D</p>
  
  <p>Thanks!</p>