Community
Participate
Working Groups
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.
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.
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.
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.
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.
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.
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?
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?
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.