Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 319726

Summary: Support persistence.xml in locations other than Java source folder
Product: [WebTools] Dali JPA Tools Reporter: Paul Fullbright <paul.fullbright>
Component: GeneralAssignee: Paul Fullbright <paul.fullbright>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: deboer, neil.hauge, paul.fullbright, shaun.smith
Version: 3.0Keywords: noteworthy, plan
Target Milestone: 3.0 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 317900    
Bug Blocks:    

Description Paul Fullbright CLA 2010-07-13 10:19:55 EDT
+++ This bug was initially created as a clone of Bug #309030 +++
+++ This is to track the issue for version 3.0, whereas the  +++
+++ original has a different fix for 2.3 maintenance         +++

Dali currently forces (defaults) the persistence.xml to be contained under META-INF in the Java source folder of a project. This makes sense for Java SE projects since persistence.xml is found at runtime using the classloader. However, when JPA is used within OSGi EEG bundles persistence.xml is normally found using methods like Bundle.getEntry() - i.e. a relative path from the root of the bundle, not on the bundle classpath.

The result is that we restrict the development project structure of OSGi bundles. If you want to be able to run directly out of the workspace, developers:
 - cannot separate Java source and resources like persistence.xml to suit their preferred project layout.
 - cannot easily use Bundle-Classpath to put Java output in a non-root folder within the bundle. (e.g. putting .classes under a /bin folder within the exported bundle)
 - cannot convert all existing WTP flexible projects (e.g. JEE web modules with a WebContent folder structure) to use JPA without moving restructuring the project.

Both PDE (IBundleProjectDescription.setBundleRoot()) and WTP (flexible project structure) already allow you to structure projects so that the Java source and 'resources' are different folders.

Please allow some flexibility in where persistence.xml is located to enable these OSGi development scenarios. My preference would be something simple, e.g. when JPA is used on PDE projects use IBundleProjectDescription.getBundleRoot() as the root instead of the Java source path. Alternately, even a JPA 'root' setting with no UI would be enough to allow adopters to create new projects or convert existing projects in this way.
Comment 1 Paul Fullbright CLA 2010-07-30 15:58:06 EDT
This has been fixed with the fix to bug 317900.  Dali now supports a fairly wide array of non java sourcepath scenarios.  If there are further issues, please open a new bug/enhancement request (for those issues not already open)