1 Reply Latest reply on Sep 14, 2015 8:14 PM by Scott Marlow

    Injecting EntityManager in a class inside a jar of a war

    Marcus Schulz Newbie

      Hello,

       

      I had a working webapp where all layers has been mixed  inside one project.

      My task was to split this into several projects because I want to reuse common classes and modules. So far good idea.

      I use maven, eclipse with m2-eclipse  and wildfly 9

       

      It resulted into the following structure:

       

      base-entities-jpa (common entities such as user and so on)

      base-controller (service classes and data access layer)

      base-webapp (some utilities for JSF, Webfilter...)

       

      Every application should base on these projects.

       

      So I have

       

      app1-model-jpa (additional entities for the specialized webapp)

      app1-controller (additional controller classes)

      app1-webapp (war file with JSF components)

       

      My current problem is that I am not able to inject the EntityManager into a class that is inside base-controller.

      I placed An "AbstractDAO" there with a member variable for the EntityManager.

      Classes, that inherit the AbstractDAO are annotated as @Stateless

       

      The projects base-* are located as jar into WEB-INF/lib of app1-webapp.

       

      I tried two days, with ear packaging, without, with CDI Producers and with @PersistencContext.

      The entity manager member still stays null.

       

      Any hint what I should do is really welcome..

      Or is it just impossible? Cannot believe ..

       

      Thanks in advance

       

      Marcus