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

Bug 335991

Summary: JPA persistence.xml file does not get created
Product: [WebTools] Dali JPA Tools Reporter: Kenneth Cheung <kennethc>
Component: GeneralAssignee: Neil Hauge <neil.hauge>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: david_williams, ktsao, neil.hauge, paul.fullbright, theivend
Version: unspecified   
Target Milestone: 2.3.3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Adding JPA facet none

Description Kenneth Cheung CLA 2011-02-01 12:00:16 EST
Build Identifier: 3.6.2

1) Create a Dynamic Web Project
2) Add project to ClearCase 7.1.2
3) Add JPA 2.0 facet

persistence.xml does not created and the following message is on the .log:

java.lang.NullPointerException
    at org.eclipse.jpt.core.internal.operations.AbstractJpaFileCreationOperation.createFile(Unknown Source)
    at org.eclipse.jpt.core.internal.operations.AbstractJpaFileCreationOperation.execute(Unknown Source)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl$1.run(Unknown Source)
    at org.eclipse.core.internal.resources.Workspace.run(Unknown Source)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(Unknown Source)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(Unknown Source)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.doExecute(Unknown Source)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.executeImpl(Unknown Source)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.cacheThreadAndContinue(Unknown Source)
    at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.execute(Unknown Source)
    at org.eclipse.jpt.core.internal.facet.JpaFacetInstallDelegate.createPersistenceXml(Unknown Source)
    at org.eclipse.jpt.core.internal.facet.JpaFacetInstallDelegate.createProjectXml(Unknown Source)
    at org.eclipse.jpt.core.internal.facet.JpaFacetInstallDelegate.execute_(Unknown Source)
    at org.eclipse.jpt.core.internal.facet.JpaFacetActionDelegate.execute(Unknown Source)
    at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.callDelegate(Unknown Source)
    at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.modifyInternal(Unknown Source)
    at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.mergeChangesInternal(Unknown Source)
    at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.access$2(Unknown Source)
    at org.eclipse.wst.common.project.facet.core.internal.FacetedProject$5.run(Unknown Source)
    at org.eclipse.core.internal.resources.Workspace.run(Unknown Source)
    at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.mergeChanges(Unknown Source)
    at org.eclipse.wst.common.project.facet.core.internal.FacetedProjectWorkingCopy.commitChanges(Unknown Source)
    at org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage$4.run(Unknown Source)
    at org.eclipse.core.internal.resources.Workspace.run(Unknown Source)
    at org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage$5.run(Unknown Source)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(Unknown Source)

Reproducible: Always

Steps to Reproduce:
1) Create a Dynamic Web Project 3.0
2) Add project to ClearCase 7.1.2
3) Add JPA 2.0 facet
Comment 1 Kenneth Cheung CLA 2011-02-03 11:10:18 EST
ClearCase Remote Client 7.1.2 and 7.1.1.4 were used.
Comment 2 Paul Fullbright CLA 2011-02-04 09:42:09 EST
Is the clearcase step necessary to reproduce this behavior?
Comment 3 Kenneth Cheung CLA 2011-02-04 10:52:00 EST
Yes, otherwise it works fine.  Thanks for looking into this.
Comment 4 David Williams CLA 2011-02-07 15:57:51 EST
In case it's not widely known ... There are some "pessimistic file system provider examples" where you can "simulate" pessimistic SCM's ... instead of installing clearcase yourself :) 

I found this old note on newsgroup, if it helps: 

= = =
In the Eclipse Help go to Platform Plug-in Developer Guide > Examples Guide > Installing the examples.

Or use the repository :pserver:anonymous@xxxxxxxxxxxxxxx:/cvsroot/eclipse and get org.eclipse.team.examples.filesystem plug-in.
= = =
Comment 5 Neil Hauge CLA 2011-02-07 16:54:09 EST
I thought we had dealt with something like this before - see bug 290061.  We should try to get this into SR2.
Comment 6 Neil Hauge CLA 2011-02-08 17:30:44 EST
Created attachment 188555 [details]
Adding JPA facet

I just tried to reproduce this in the latest Helios SR2 code using the pessimistic file system provider and everything worked as expected.  After adding the JPA facet I was presented with the attached dialog. The persistence.xml file was created.

Are you able to reproduce using base WTP?  If this is unique to ClearCase, you may need to debug yourself and post information on what is happening.  Everything looks good in the code from my end.
Comment 7 Kenneth Cheung CLA 2011-02-08 18:51:02 EST
We'll definitely try that.  Could you give me a link that we can get the exact build you tried with?  Thanks.
Comment 8 Neil Hauge CLA 2011-02-09 09:51:18 EST
Sure...this is the build I am targeting.

http://download.eclipse.org/webtools/downloads/drops/R3.2.3/M-3.2.3-20110203200212/
Comment 9 Kenneth Cheung CLA 2011-02-16 16:39:06 EST
After some debugging with a CCRC myself I found that the projects are actually moved away from the workspace to the ClearCase views in the file system.

As a result in org.eclipse.jpt.core.internal.operations.AbstractJpaFileCreationOperation:
	protected void createSourceFolder() throws ExecutionException {
		// Get the source folder name from the data model
		String folderPath = model.getStringProperty(SOURCE_FOLDER);
		IProject project = getProject();
		IWorkspaceRoot root = project.getWorkspace().getRoot();
		IContainer container = root.getContainerForLocation(root.getLocation().append(new Path(folderPath)));

container equals null and
		this.createdSourceFolder = container;

and hence NullPointerException in
	protected void createFile() {
		String filePath = getDataModel().getStringProperty(FILE_PATH);
		IFile newFile = this.createdSourceFolder.getFile(new Path(filePath));

Does it explain the NPE and if so is it possible to make it work for source controls that move file away from the local workspace?  Thanks.
Comment 10 Neil Hauge CLA 2011-02-16 16:57:56 EST
That would certainly explain the problem.  We just fixed a very similar issue in head (and 2.3.4 maintenance) that will likely address this issue as well.  See bug 336553.  Try to reproduce this with the patch attached to that bug and let me know if that fixes the problem.
Comment 11 Paul Fullbright CLA 2011-02-16 17:15:15 EST
I agree.  I think you'll find that fix will work for you, if that's what's causing the issue.
Comment 12 Kenneth Cheung CLA 2011-02-16 17:35:13 EST
Yes, that patch did the trick.  Thanks.
Comment 13 Neil Hauge CLA 2011-02-16 18:02:06 EST
Fixed as a result of the changes for bug 336553.
Comment 14 David Williams CLA 2011-02-17 13:42:48 EST
Is this bug, or bug 336553 a regression? Or, just happened to be discovered now?
Comment 15 Neil Hauge CLA 2011-02-17 14:05:23 EST
(In reply to comment #14)
> Is this bug, or bug 336553 a regression? Or, just happened to be discovered
> now?

It looks like we almost completely avoided this bug in the Helios stream as it was introduced in WTP 3.2.2, a result of the change made for bug 309030.  Almost made it for SR2.
Comment 16 Neil Hauge CLA 2011-02-17 16:47:59 EST
After hearing from multiple large adopters and discussing with WTP PMC, we have decided to try and respin the WTP Helios SR2 candidate to include the fix for this issue.  There doesn't seem to be a workaround for the ClearCase usage, and as a result this effectively blocks the creation of a usable Dali project.