3 Replies Latest reply on Aug 3, 2011 7:10 AM by Alex Ander

    CDI inside do not work inside WEB-INF/lib of WAR-App

    Alex Ander Newbie

      Hi @ll,


      after searching in forums and reading this article: https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7

      I could not solve my problem, maybe u can help.


      I have following 3 classes in module.jar:





      public class JaxRsActivator extends Application {

         /* class body intentionally left blank */





      public class Resources {

                // use @SuppressWarnings to tell IDE to ignore warnings about field not

                // being referenced directly



                @PersistenceContext(unitName = "myUnit1")

                private EntityManager em;




                Logger getLog(InjectionPoint ip) {

                          String category = ip.getMember().getDeclaringClass().getName();

                          return Logger.getLogger(category);









      public class StatisticResourceRESTService {



                private EntityManager em;



                private Logger log;






                @Produces({ MediaType.TEXT_PLAIN })


                public Response retrieveTest(

                                    @HeaderParam("X-Request-Id") final String requestId,

                                    @Context final Request request) {

                          Variant variant = VariantsBuilder.buildVariant(request, new String[]{MediaType.TEXT_PLAIN});

                          String s = new String("Hello with umlauts äöü!!!");


                          ResponseBuilder builder = Response.status(Response.Status.OK);



                    return builder.build();




      If i deploy this 3 classes inside module.war/WEB-INF/classes/../*.class

      the CDI of em and log works fine!!!



      If I deploy the module.jar inside the module.war/WEB-INF/lib/module.jar.

      The deployment fail with:

      WELD-001408 Unsatisfied dependencies for type [EntityManager] with qualifiers [@Default] at injection point [[field] @Inject private...

      same for Log


      Whats wrong here? What should I do to get the CDI in case 2 to run.


      !!! I can access the REST service in both cases, but in case 2 i get NullPointerException at log.info...


      many thx