[jboss-jira] [JBoss JIRA] (WFLY-6485) add JPA dependency in subdeployments to avoid NPE

Martin Kouba (JIRA) issues at jboss.org
Tue Apr 5 05:22:00 EDT 2016


    [ https://issues.jboss.org/browse/WFLY-6485?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13186495#comment-13186495 ] 

Martin Kouba commented on WFLY-6485:
------------------------------------

Hi [~smarlow], I've just noticed this line: [WeldDeploymentProcessor.java#L183|https://github.com/wildfly/wildfly/blob/master/weld/src/main/java/org/jboss/as/weld/deployment/processors/WeldDeploymentProcessor.java#L183]. And I wonder whether changing the line to {{getJpaDependencies(subDeployment, jpaServices)}} couldn't fix the issue?

> add JPA dependency in subdeployments to avoid NPE 
> --------------------------------------------------
>
>                 Key: WFLY-6485
>                 URL: https://issues.jboss.org/browse/WFLY-6485
>             Project: WildFly
>          Issue Type: Bug
>          Components: CDI / Weld, JPA / Hibernate
>    Affects Versions: 10.0.0.Final
>            Reporter: Scott Marlow
>            Assignee: Scott Marlow
>
> WeldDeploymentProcessor only processes top level deployments (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.
> {quote}
> 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)
> {quote}
> Potential fix is at [https://github.com/scottmarlow/wildfly/tree/jpaNPE]



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list