Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1851

Could not inject persistence unit into CDI managed bean. => When activating CDI for deployment with persistence context.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Critical
    • None
    • None
    • None
    • None

    Description

      The issues WFLY-3425 and WFLY-3698 have been marked as resolved but I don't see that this behavior has been fixed.

      Please see this problem: http://stackoverflow.com/questions/28149056/jbas016069-error-injecting-persistence-unit-into-cdi-managed-bean-when-deplo?noredirect=1#comment44670857_28149056

      The problem is that if you deploy a module (EJB-JAR, EAR, ...) with a JPA persistence setup and maybe DAOs in it and you include a beans.xml with bean-discovery-mode set to 'all' or 'annotated' then at a first glance everything works fine, f.i. if you work with the DAOs inside this module. But as soon as you deploy another module where you want to inject these DAOs, you need to set a dependency to the first module in order to be able to use @Inject. But at deployment time CDI tries to inject the persistence unit into the DAO and fails with the following error:

      java.lang.IllegalArgumentException: JBAS016069: Error injecting persistence unit into CDI managed bean. Can't find a persistence unit named indra in deployment test-ui.war
      	at org.jboss.as.weld.services.bootstrap.WeldJpaInjectionServices.getScopedPUName(WeldJpaInjectionServices.java:110)
      	at org.jboss.as.weld.services.bootstrap.WeldJpaInjectionServices.registerPersistenceContextInjectionPoint(WeldJpaInjectionServices.java:73)
      ...
      

      Is this a bug or intended behavior? I think the injection of the DAOs into other modules is a valid usecase and thus disabling CDI for the DAO-module is not an option.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              stanley.hillner Stanley Hillner (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: