Community
Participate
Working Groups
Prerequisites: * Install the Libra OSGi facet from the p2 repository of latest maintenance build: http://download.eclipse.org/libra/maintenance/snapshot Steps to reproduce: 1. Create new JPA project. 2. Right-click on the project > Configure > Convert to OSGi Bundle project. 3. Make sure the JPA project is selected and click Finish. This wizard will install the OSGi facet. As a result of installing the OSGi facet, the src/META-INF folder is moved to <project-root>/META-INF. See bug 341398 for details. But the JPA model is not refreshed properly. The JPA Content node is empty and tools like the JPA Diagram Editor does not work. Workaround: 1. Right-click on the project > Validate. This refreshes the JPA model, but leaves an error marker on the META-INF/persistence.xml file. 2. Repeat again: Right-click on the project > Validate. This removes the error marker. As part of bug 341398 I tried to refresh the JPA model in the install delegate of the OSGi facet, but could not find the proper way to do this. I've tried lots of combination using the following API, but with no luck: jpaProject.update(monitor); jpaProject.updateAndWait(); jpaProject.synchronizeContextModelAndWait(); JptJpaCorePlugin.rebuildJpaProject(project); ValidationFramework.getDefault().validate(new IProject[] { project }, false, false, monitor); ValidationFramework.getDefault().validate(project.getFile(new Path(OSGiBundleFacetUtils.PERSISTENCE_URI)), monitor); Neil, Shaun, could you give a hint here?
Probably the easiest workaround (from a user perspective) would be a project clean, which should resolve any stale model/validation issues. I would think that programatically the JptJpaCorePlugin.rebuildJpaProject(project) would have done the job. Ideally we would be listening for this type of change and would be updating the project as required, but this is obviously not in place yet. Give rebuildJpaProject another try and try to confirm that the rebuild is taking place at the right time.