-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in the PersistenceUnitProcessor.findPersistenceArchives(ClassLoader loader, String descriptorPath) - bugfix #1383
Conversation
…er loader, String descriptorPath) - bugfix This small fix allows using/loading persistence.xml from WAR file from .../WEB-INF/classes/META-INF/persistence.xml location in JSE environment. It is still required to point EclipseLink (EntityManagerFactory) to this location in JSE environment by: System.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "WEB-INF/classes/META-INF/persistence.xml"); or Properties persistenceUnitProperties = new Properties(); persistenceUnitProperties.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "WEB-INF/classes/META-INF/persistence.xml"); EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("test-jpa-pu2", persistenceUnitProperties); Before this fix ValidationException e.g. Internal Exception: Exception [EclipseLink-7357] (Eclipse Persistence Services - 4.0.0.v202112161344): org.eclipse.persistence.exceptions.ValidationException Exception Description: URL [jar:file:/tmp/test1348.war!/WEB-INF/classes/META-INF/persistence.xml] for resource [WEB-INF/classes/META-INF/persistence.xml] does not belong to a valid persistence root (as per JPA Specification) was thrown Fixes eclipse-ee4j#1348 Signed-off-by: Radek Felcman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be probably good to add a (unit) test for this class to cover valid/invalid scenarios to have something for the future reference
…er loader, String descriptorPath) - bugfix and unit test This small fix allows using/loading persistence.xml from WAR file from .../WEB-INF/classes/META-INF/persistence.xml location in JSE environment. It is still required to point EclipseLink (EntityManagerFactory) to this location in JSE environment by: System.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "WEB-INF/classes/META-INF/persistence.xml"); or Properties persistenceUnitProperties = new Properties(); persistenceUnitProperties.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "WEB-INF/classes/META-INF/persistence.xml"); EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("test-jpa-pu2", persistenceUnitProperties); Before this fix ValidationException e.g. Internal Exception: Exception [EclipseLink-7357] (Eclipse Persistence Services - 4.0.0.v202112161344): org.eclipse.persistence.exceptions.ValidationException Exception Description: URL [jar:file:/tmp/test1348.war!/WEB-INF/classes/META-INF/persistence.xml] for resource [WEB-INF/classes/META-INF/persistence.xml] does not belong to a valid persistence root (as per JPA Specification) was thrown Fixes eclipse-ee4j#1348 Signed-off-by: Radek Felcman <[email protected]>
OK it's done by second commit. |
...it/java/org/eclipse/persistence/testing/tests/jpa/advanced/PersistenceUnitProcessorTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Radek Felcman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…er loader, String descriptorPath) - bugfix (eclipse-ee4j#1383) Bug in the PersistenceUnitProcessor.findPersistenceArchives(ClassLoader loader, String descriptorPath) - bugfix This small fix allows using/loading persistence.xml from WAR file from .../WEB-INF/classes/META-INF/persistence.xml location in JSE environment. It is still required to point EclipseLink (EntityManagerFactory) to this location in JSE environment by: System.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "WEB-INF/classes/META-INF/persistence.xml"); or Properties persistenceUnitProperties = new Properties(); persistenceUnitProperties.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "WEB-INF/classes/META-INF/persistence.xml"); EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("test-jpa-pu2", persistenceUnitProperties); Before this fix ValidationException e.g. Internal Exception: Exception [EclipseLink-7357] (Eclipse Persistence Services - 4.0.0.v202112161344): org.eclipse.persistence.exceptions.ValidationException Exception Description: URL [jar:file:/tmp/test1348.war!/WEB-INF/classes/META-INF/persistence.xml] for resource [WEB-INF/classes/META-INF/persistence.xml] does not belong to a valid persistence root (as per JPA Specification) was thrown Fixes eclipse-ee4j#1348 Signed-off-by: Radek Felcman <[email protected]> (cherry picked from commit 9417d47)
This small fix allows using/loading persistence.xml from WAR file from
.../WEB-INF/classes/META-INF/persistence.xml
location in JSE environment.It is still required to point EclipseLink (EntityManagerFactory) to this location in JSE environment by:
System.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "WEB-INF/classes/META-INF/persistence.xml");
or
Properties persistenceUnitProperties = new Properties(); persistenceUnitProperties.setProperty(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, "WEB-INF/classes/META-INF/persistence.xml"); EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("test-jpa-pu2", persistenceUnitProperties);
Before this fix ValidationException
e.g.
Internal Exception: Exception [EclipseLink-7357] (Eclipse Persistence Services - 4.0.0.v202112161344): org.eclipse.persistence.exceptions.ValidationException Exception Description: URL [jar:file:/tmp/test1348.war!/WEB-INF/classes/META-INF/persistence.xml] for resource [WEB-INF/classes/META-INF/persistence.xml] does not belong to a valid persistence root (as per JPA Specification)
was thrown
Fixes #1348
Signed-off-by: Radek Felcman [email protected]