Uploaded image for project: 'Aries'
  1. Aries
  2. ARIES-1992

Override PersistenceUnit props are lost if DataSource is not yet available

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • jpa-2.7.2, jpa-2.7.3
    • jpa-2.7.4
    • JPA
    • None
    • Karaf 4.2.8 / 4.4.3 on Windows 10 and Alpine

      • Pax JDBC
      • Hibernate ORM 5.4

    Description

      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

      Steps to Reproduce

      1. Start Karaf
      2. Deploy a PersistenceUnit and DataSource
      3. Add an org.apache.aries.jpa.<pu-name>.cfg file in ${karaf.etc}. Set a new property.
      4. Inspect the properties of the corresponding EntityManagerFactory (by executing service:list EntityManagerFactory)
      5. Restart Karaf
      6. Inspect the properties of the EntityManagerFactory (by executing service:list EntityManagerFactory) again

      Actual Results

      1. The properties of the EntityManagerFactory change during a Karaf restart.
      2. The additional properties from ${karaf.etc}/org.apache.aries.jpa.<pu-name>.cfg are not applied
      3. An error is logged
        java.lang.IllegalArgumentException: The persistence unit <pu-name> has incomplete configuration and cannot be created.
        

      Expected Results

      1. The published EMF before restarting should be identical to the EMF after restarting Karaf

      Conjecture

      ManagedEMF 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.

      Attachments

        Issue Links

          Activity

            People

              jbonofre Jean-Baptiste Onofré
              Robert Schulte Robert Schulte
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: