Bug in the PersistenceUnitProcessor.findPersistenceArchives(ClassLoader loader, String descriptorPath) - bugfix (#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 #1348

Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
2 files changed
tree: d35ca43497ad820bc6a84791ba8aaef0c7cfce1c
  1. .github/
  2. bundles/
  3. dbws/
  4. etc/
  5. features/
  6. foundation/
  7. jpa/
  8. moxy/
  9. performance/
  10. project-admin/
  11. sdo/
  12. src/
  13. testing/
  14. utils/
  15. .gitattributes
  16. .gitignore
  17. .lgtm.yml
  18. CONTRIBUTING.md
  19. findbugs-exclude.xml
  20. LICENSE.md
  21. NOTICE.md
  22. pom.xml
  23. README.md
  24. SECURITY.md
README.md

Language grade: Java Total alerts

EclipseLink master (3.1.x) Maven Central Jakarta Staging (Snapshots) Master Build Status

EclipseLink 3.0.0 Maven Central 3.0 Build Status

EclipseLink 2.7.x Maven Central 2.7.x  Build Status

EclipseLink

The EclipseLink project's goal is to provide a complete persistence framework that is both comprehensive and universal. It will run in any Java environment and read and write objects to virtually any type of data source, including relational databases, XML, JSON, or EIS systems. EclipseLink will focus on providing leading edge support, including advanced feature extensions, for the dominant persistence standards for each target data source; Jakarta Persistence for relational databases, Jakarta XML Binding for XML, Jakarta Connectors for EIS and other types of legacy systems, and Service Data Objects (SDO).

This project is part of the EclipseLink project.

License

EclipseLink is dual licensed under an EPL 2.0 and EDL 1.0 license.

Contributing

We use contribution policy, which means we can only accept contributions under the terms of Eclipse Contributor Agreement.

Links

Issue/bug trackers

Hint: If it‘s possible, it helps if some test reproducer is attached to the new bug. If it’s not possible, attached entities and persistence.xml file should help too for JPA related bugs. For MOXy, entities and XML or JSON resources/files are welcome.