[ 
https://issues.apache.org/jira/browse/ARIES-1992?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jean-Baptiste Onofré reassigned ARIES-1992:
-------------------------------------------

    Assignee: Jean-Baptiste Onofré

> Override PersistenceUnit props are lost if DataSource is not yet available
> --------------------------------------------------------------------------
>
>                 Key: ARIES-1992
>                 URL: https://issues.apache.org/jira/browse/ARIES-1992
>             Project: Aries
>          Issue Type: Bug
>          Components: JPA
>    Affects Versions: jpa-2.7.2
>         Environment: Karaf 4.2.8 on Windows 10 and Alpine
> * Pax JDBC
>  * Hibernate ORM 5.4
>            Reporter: Robert Schulte
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>
> h1. Overview
> We have a similar setup to the one described here:
> [http://karaf.922171.n3.nabble.com/Aries-JPA-The-persistence-unit-has-incomplete-configuration-and-cannot-be-created-td4053148.html]
> We use
>  * Apache Karaf
>  * Pax JDBC
>  * Aries JPA
>  * Hibernate ORM
> We use Pax JDBC to configure a DataSource and also use the pre-hook for 
> Liquibase migration. Since we support multiple databases, we have to set 
> _org.hibernate.dialect_ dynamically. We have a bundle with persistence.xml, 
> that sets a default _org.hibernate.dialect_ . We overwrite the dialect by 
> setting it in org.apache.aries.jpa.<pu-name>.cfg in ${karaf.etc}.
>  After migrating from Karaf 4.1.4 to 4.2.8 (jpa 2.6.1 -> 2.7.2) this does not 
> work anymore
> h1. Steps to Reproduce
>  # Start Karaf
>  # Deploy a PersistenceUnit and DataSource
>  # Add an org.apache.aries.jpa.<pu-name>.cfg file in ${karaf.etc}. Set a new 
> property.
>  # Inspect the properties of the corresponding EntityManagerFactory (by 
> executing {{service:list EntityManagerFactory}})
>  # Restart Karaf
>  # Inspect the properties of the EntityManagerFactory (by executing 
> {{service:list EntityManagerFactory}}) again
> h1. Actual Results
>  # The properties of the EntityManagerFactory change during a Karaf restart.
>  # The additional properties from 
> ${karaf.etc}/org.apache.aries.jpa.<pu-name>.cfg are not applied
>  # An error is logged
> {noformat}
> java.lang.IllegalArgumentException: The persistence unit <pu-name> has 
> incomplete configuration and cannot be created.
> {noformat}
> h1. Expected Results
>  # The published EMF before restarting should be identical to the EMF after 
> restarting Karaf
> h1. Conjecture
> [ManagedEMF|https://github.com/apache/aries-jpa/blob/master/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/ManagedEMF.java#L75]
>  is notified about updated props before a DataSource is available. This 
> results in the aforementioned {{IllegalArgumentException}}. The props from 
> the Config Admin's call to {{updated}} are now lost. When a DS or DSF is 
> discovered by the respective ServiceTracker, an EMF will be created and 
> published, but the override properties will not be passed again since they 
> have already been handed to the ManagedService.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to