Community
Participate
Working Groups
Running some automated JUnit tests revealed a strange problem. When they create JPA 1.0 projects the first one is created without persistence.xml. All the rest are created with persistence.xml. I've debugged the problem and appears that the first invokation of JptCorePlugin.getJpaProjectManager() registers an instance of GenericJpaProjectManager$FacetedProjectListener which is responsible for creation of the persistence.xml. During the creation of the first project the listener is still not registered and that's why the JPA project is corrupted. At some point during the creation of the JPA project the listener is being registered and that's why every subsequently created JPA project is being created just fine. As a workaround in the setUp() method(s) of our automated test(s) before any project creation we invoke JptCorePlugin.getJpaProjectManager(). After that all the JPA projects are created just fine. We were able to reproduce the problem manually by creating a JPA project in a brand new clean workspace.
(In reply to comment #0) > We were able to reproduce the problem manually by creating a JPA project in > a brand new clean workspace. Interesting. Are you able to reproduce this 100% of the time by creating a JPA 1.0 project inside a clean workspace? I have not been able to reproduce as of yet.
The only way I can reproduce this issue is if I remove the focus listener that is installed in JptUiPlugin.start. As soon as the new JPA project wizard is opened JptUiPlugin gets the focus event and calls setJavaElementChangeListener(boolean) which calls getJpaProjectManager() and initializes it. If I remove that focus listener I see the issue you are having. Are you not using JptUiPlugin? The fix for this is that the persistence.xml file should *not* be created in a facet install listener. We have been talking about changing this recently due to a deadlock reported in another bug. I looked at our tests to figure out why we don't have the same problem as you and discovered we are calling JptCorePlugin.getJpaProjectManager() in JptCoreTestsPlugin in order to reflectively execute the method handleEventsSynchronously. Thus we don't hit this problem. I am targeting this to 3.0, though it is possible the deadlock fix for maintenance will solve this issue as well.
(In reply to comment #1) > (In reply to comment #0) > > We were able to reproduce the problem manually by creating a JPA project in > > a brand new clean workspace. > Interesting. Are you able to reproduce this 100% of the time by creating a JPA > 1.0 project inside a clean workspace? > I have not been able to reproduce as of yet. Yes, it's reproducible 100%
> Are you not using JptUiPlugin? You are correct - we are NOT using JptUiPlugin: 1. In the JUnit tests we create projects though API 2. Manually, we create proprietary kind of (JPA) projects, by using proprietary wizards. That completely explains why we hit the problem 100% and you don't ... at all.
This has been fixed as a result of the fix for bug 303670.