Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 357810 - [Maven] Persistence.xml does not get picked up (about 50% of the time) when importing an existing project
Summary: [Maven] Persistence.xml does not get picked up (about 50% of the time) when i...
Status: RESOLVED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: 2.3.4   Edit
Hardware: PC Windows 7
: P1 normal (vote)
Target Milestone: 3.0.2   Edit
Assignee: Paul Fullbright CLA
QA Contact:
URL:
Whiteboard: fix_ready
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-15 10:13 EDT by Paul Fullbright CLA
Modified: 2012-03-07 10:24 EST (History)
3 users (show)

See Also:


Attachments
proposed patch (1.56 KB, text/plain)
2011-09-15 10:30 EDT, Paul Fullbright CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Fullbright CLA 2011-09-15 10:13:16 EDT
Create a (working) JPA project with persistence.xml in a *non-source* folder.  Delete project from workspace (but not from file system).  Import project into workspace.  About half the time (depending on user processor) the project's persistence.xml is not resolved.
Comment 1 Paul Fullbright CLA 2011-09-15 10:30:04 EDT
Created attachment 203416 [details]
proposed patch

In some cases, such as classpath changes and project imports (apparently) a project changed event is transmitted after our resource models have been built and our response to that is to clean up "dead" files.  The problem is that the determination of what a dead file is only checked that the file be on the classpath and didn't hook into the resource locator framework.  This patch fixes that.
Comment 2 Neil Hauge CLA 2011-09-28 13:57:14 EDT
Workround:

It should be noted that performing a project "Clean..." will result in the rebuilding of the project and should be a reliable workaround for this issue.  After performing the Clean, the JPA functionality should work correctly.
Comment 3 Anttix Mising name CLA 2011-10-18 23:18:16 EDT
I would like to add that the problem manifests itself also when adding a new dependency to a Mavenized project in a form of: "The persistence.xml file does not have recognized content." error.
After re-updating the project configuration (Maven->Update project configuration) the error disappears again.
Comment 4 Paul Fullbright CLA 2011-11-15 16:50:52 EST
Haven't had any comments on the patch, so I'm committing (to head (3.1 rc2) and 3.0 streams) and resolving this fixed.
Comment 5 Leonard Theivendra CLA 2012-03-06 10:08:46 EST
Hi Paul, just wanted to clarify if this fix is also in the Dali 2.x stream that aligns with WTP 3.2.x, and if not, any chance of a backport? We're seeing this issue on WTP 3.2.x intermittently in scenarios such as importing of project archives that undergo workspace migration.
Comment 6 Paul Fullbright CLA 2012-03-06 16:58:29 EST
This fix can't be in the Dali 2.x stream, because the ResourceLocator implementation isn't in the 2.x stream.  And I'm also pretty sure non-source folders aren't supported in 2.x.

What exactly is it you're having problems with?
Comment 7 Leonard Theivendra CLA 2012-03-07 09:45:17 EST
The symptoms in the adopter product based on WTP 3.2.x is quite similar to the ones in this bug.. basically about 25-50% of the time in importing pre-existing JPA projecta in archive files, and especially when importing and re-targeting the runtime on the project (since the runtime the project was targeting does not exist in the workspace), the "The persistence.xml file does not have recognized content." error shows up.  And it goes away when doing a project -> clean.  The JPA projects are of the normal variety, with the persistence.xml in a source folder, etc.

Sounds like it could due to what you describe in Comment #1? i.e. project change events due to classpath changes transmitted after the JPA resource models are built?
Comment 8 Paul Fullbright CLA 2012-03-07 10:24:02 EST
The behavior was due to a change in what was a proper location for an xml resource, provided by the resource locator functionality.  This was new behavior, as the code that cleans up "dead" files was using outdated logic.  However in WTP 3.2 it's not quite outdated.

Can you provide a more in depth use case that demonstrates the behavior?  I tried a number of times to duplicate the behavior using the use case from comment #1 (only with the file in a source folder) to no avail.

This might be a new bug and not the bug detailed here.