From f9f55b74950a2fb39f76209c5392676d3e4d0e77 Mon Sep 17 00:00:00 2001 From: jhh Date: Thu, 9 Apr 2020 13:31:38 -0500 Subject: rename jpa persistence file After inspecting the fat jar generated by brmsgw, noticed that the persistence.xml included from here it was overriden by another one, therefore the persistence unit was not available. This may solve the issue for the brmsgw, as with a far jar build, there are the risks of collisions such as this of files with the same name. Issue-ID: POLICY-2471 Signed-off-by: jhh Change-Id: I91cf2b6d3d2f5086d77795e08800ca96d984c214 --- .../onap/policy/common/im/IntegrityMonitor.java | 4 ++ .../src/main/resources/META-INF/persistence.xml | 49 ---------------------- .../src/main/resources/META-INF/persistenceIM.xml | 49 ++++++++++++++++++++++ .../policy/common/im/IntegrityMonitorTestBase.java | 2 + 4 files changed, 55 insertions(+), 49 deletions(-) delete mode 100644 integrity-monitor/src/main/resources/META-INF/persistence.xml create mode 100644 integrity-monitor/src/main/resources/META-INF/persistenceIM.xml (limited to 'integrity-monitor/src') diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java index 3cb708e2..d12a9bde 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java @@ -44,6 +44,7 @@ import javax.persistence.LockModeType; import javax.persistence.Persistence; import javax.persistence.Query; import org.apache.commons.lang3.StringUtils; +import org.eclipse.persistence.config.PersistenceUnitProperties; import org.onap.policy.common.im.jmx.ComponentAdmin; import org.onap.policy.common.im.jmx.ComponentAdminMBean; import org.onap.policy.common.im.jmx.JmxAgentConnection; @@ -229,6 +230,9 @@ public class IntegrityMonitor { // // Create the entity manager factory // + if (!properties.containsKey(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML)) { + properties.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "META-INF/persistenceIM.xml"); + } emf = Persistence.createEntityManagerFactory(getPersistenceUnit(), properties); // // Did it get created? diff --git a/integrity-monitor/src/main/resources/META-INF/persistence.xml b/integrity-monitor/src/main/resources/META-INF/persistence.xml deleted file mode 100644 index 7aff9219..00000000 --- a/integrity-monitor/src/main/resources/META-INF/persistence.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - org.eclipse.persistence.jpa.PersistenceProvider - org.onap.policy.common.im.jpa.ImTestEntity - org.onap.policy.common.im.jpa.StateManagementEntity - org.onap.policy.common.im.jpa.ForwardProgressEntity - org.onap.policy.common.im.jpa.ResourceRegistrationEntity - NONE - - - - - - - - org.eclipse.persistence.jpa.PersistenceProvider - org.onap.policy.common.im.jpa.ImTestEntity - org.onap.policy.common.im.jpa.StateManagementEntity - org.onap.policy.common.im.jpa.ForwardProgressEntity - org.onap.policy.common.im.jpa.ResourceRegistrationEntity - NONE - - - - - diff --git a/integrity-monitor/src/main/resources/META-INF/persistenceIM.xml b/integrity-monitor/src/main/resources/META-INF/persistenceIM.xml new file mode 100644 index 00000000..7aff9219 --- /dev/null +++ b/integrity-monitor/src/main/resources/META-INF/persistenceIM.xml @@ -0,0 +1,49 @@ + + + + + + + org.eclipse.persistence.jpa.PersistenceProvider + org.onap.policy.common.im.jpa.ImTestEntity + org.onap.policy.common.im.jpa.StateManagementEntity + org.onap.policy.common.im.jpa.ForwardProgressEntity + org.onap.policy.common.im.jpa.ResourceRegistrationEntity + NONE + + + + + + + + org.eclipse.persistence.jpa.PersistenceProvider + org.onap.policy.common.im.jpa.ImTestEntity + org.onap.policy.common.im.jpa.StateManagementEntity + org.onap.policy.common.im.jpa.ForwardProgressEntity + org.onap.policy.common.im.jpa.ResourceRegistrationEntity + NONE + + + + + diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java index 1bb7cd96..c034482f 100644 --- a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java +++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java @@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; +import org.eclipse.persistence.config.PersistenceUnitProperties; import org.onap.policy.common.utils.jpa.EntityTransCloser; import org.onap.policy.common.utils.test.log.logback.ExtractAppender; import org.onap.policy.common.utils.time.CurrentTime; @@ -163,6 +164,7 @@ public class IntegrityMonitorTestBase { properties.put(IntegrityMonitorProperties.NODE_TYPE, NODE_TYPE); properties.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, String.valueOf(REFRESH_INTERVAL_MS)); + properties.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "META-INF/persistenceIM.xml"); emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT, makeProperties()); -- cgit 1.2.3-korg