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

Bug 405320

Summary: Intermittent failure on JPA project creation when starting Eclipse
Product: [WebTools] Dali JPA Tools Reporter: Neil Hauge <neil.hauge>
Component: JPAAssignee: Neil Hauge <neil.hauge>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: brian.vosburgh, jolene.moffitt, nan.n.li, raghunathan.srinivasan
Version: 3.3Flags: neil.hauge: pmc_approved? (david_williams)
raghunathan.srinivasan: pmc_approved+
neil.hauge: pmc_approved? (naci.dai)
neil.hauge: pmc_approved+
neil.hauge: pmc_approved? (cbridgha)
neil.hauge: review+
brian.vosburgh: review+
Target Milestone: 3.3 RC3   
Hardware: PC   
OS: Windows 7   
Whiteboard: PMC_approved
Bug Depends on: 408506, 419080    
Bug Blocks:    
Attachments:
Description Flags
NPE
none
Temp patch
none
Temp patch none

Description Neil Hauge CLA 2013-04-09 17:05:09 EDT
Created attachment 229540 [details]
NPE

On occasion, when opening a workspace from a run config in dev where there are multiple projects, I am hitting an exception which can prevent one or more JPA projects from being built.  The exception and subsequent failure are intermittent and appear to affect projects randomly when encountered.

java.lang.NullPointerException
	at org.eclipse.jpt.jpa.core.internal.AbstractJpaProject.fileResourceLocationIsValid(AbstractJpaProject.java:608)

Full stack is attached.

Cleaning the project is not successful, as the state appears to be persisted, and results in the following JPA tooling error message - "This project has the JPA facet, but no JPA project could be created. See the error log for more details."  Cleans do not cause another NPE to be generated in the log.

I haven't been able to get into this state in debug mode yet, but need to try more.
Comment 1 Neil Hauge CLA 2013-04-29 16:36:58 EDT
More reproduction steps:

-persistence.xml file is open from one of the projects to cause JPA project to be built at startup (this is key)
-seems to occur with 2.0 and 2.1 Generic projects, haven't seen it with EclipseLink platform projects yet, but this may be a coincidence.
-multiple projects open in the workspace, no java source or entities required to be in any of the projects, just the persistence.xml
Comment 2 Neil Hauge CLA 2013-04-29 17:38:31 EDT
After some println debugging it appears that the resource locator is coming back null in the following call:

return this.getProjectResourceLocator().locationIsValid(file.getParent());

More specifically, the following is returning null during project build:

return (ProjectResourceLocator)this.project.getAdapter(ProjectResourceLocator.class);
Comment 3 Neil Hauge CLA 2013-05-28 13:16:23 EDT
This issue is going to be addressed in the platform in Kepler SR1.  As a result, we need to put in a temporary fix into RC3.
Comment 4 Neil Hauge CLA 2013-05-31 11:26:48 EDT
Created attachment 231821 [details]
Temp patch

Attaching temporary patch to address this issue until the root bug is fixed in the platform.  This fix will try to load the factory again (if null the first time) through a different mechanism, essentially creating a delay that will alleviate the race condition.  It is not a perfect fix, but is employed in DTP as a way to work around the same issue, so this fix has been proven in production.
Comment 5 Neil Hauge CLA 2013-05-31 11:28:26 EDT
Created attachment 231822 [details]
Temp patch

Comment wasn't added in original patch...now commented.
Comment 6 Brian Vosburgh CLA 2013-05-31 12:02:45 EDT
Maybe file another bug, targeted at Kepler SR1; so we don't forget. :-)
Comment 7 Neil Hauge CLA 2013-05-31 12:09:46 EDT
(In reply to comment #6)
> Maybe file another bug, targeted at Kepler SR1; so we don't forget. :-)

Good idea - bug 409608 filed for this purpose.
Comment 8 Neil Hauge CLA 2013-05-31 12:50:07 EDT
JPA core tests pass.
Comment 9 Neil Hauge CLA 2013-05-31 12:52:51 EDT
    Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. 

This bug prevents JPA projects from loading at start-up.  The workbench must be restarted to correct the issue, and upon doing so, you may end up with the same result.

    Is there a work-around? If so, why do you believe the work-around is insufficient? 

No workaround.  This is a race condition, so no way to predict how it will affect a given user.

    How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? 

Manually tested and unit tests have passed.  

    Give a brief technical overview. Who has reviewed this fix? 

See comment 4.  Brian has reviewed the fix.

    What is the risk associated with this fix? 

Very low risk.
Comment 10 Neil Hauge CLA 2013-05-31 14:56:40 EDT
Fixed for RC3.
Comment 11 Neil Hauge CLA 2013-05-31 14:56:49 EDT
.
Comment 12 Jolene Moffitt CLA 2013-07-24 08:54:49 EDT
Verified in RC3 as well as regression tested in I-3.6.0-20130718045541 and M-3.5.1-20130719145056.  The steps to test this bug can be found at http://wiki.eclipse.org/Dali_3.3_RC3_Release