Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-6485

add JPA dependency in subdeployments to avoid NPE

    XMLWordPrintable

Details

    Description

      WeldDeploymentProcessor only processes top level deployments (jpa dependencies for subdeployments are skipped). This means that subdeployments that CDI inject a persistence unit/context, will not add a dependency on the JPA PersistenceUnitService. As a result, the PersistenceUnitService is referenced before it is started (which leads to PersistenceUnitService.entityManagerFactory being null).

      We should avoid the following NPE by ensuring that dependencies on the JPA persistence unit are added for all sub-deployments.

      Caused by: java.lang.NullPointerException
      at org.jboss.as.jpa.container.TransactionScopedEntityManager.createEntityManager(TransactionScopedEntityManager.java:186)
      at org.jboss.as.jpa.container.TransactionScopedEntityManager.getEntityManager(TransactionScopedEntityManager.java:91)
      at org.jboss.as.jpa.container.AbstractEntityManager.find(AbstractEntityManager.java:212)

      Potential fix is at https://github.com/scottmarlow/wildfly/tree/jpaNPE

      Attachments

        Issue Links

          Activity

            People

              smarlow1@redhat.com Scott Marlow
              smarlow1@redhat.com Scott Marlow
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: