Community
Participate
Working Groups
Build ID: I20070601-1539 When I close a JPA project I see an error dialog and stack trace C is logged. When I reopen this project, I see two NPEs logged (stack trace B), the persistence.xml file seems hosed after reopening the project and a stack overflow results. Steps to Reproduce: 1) Open an Entity in the Java editor and click around a bit, observe the details view to ensure that the JPA models have been setup correctly. 2) Close project (Trace C logged) 3) Open Project (Trace B logged twice) 4) Open persistence.xml file to observe a truncated xml file in the editor - (only the XML header remains and the XML editor is marked dirty). If you attempt to close the file, you will get a stack overflow error. 5) If you opened an Entity (instead of persistence.xml), the JPA Details view seems to work fine, however JPA validation does not work - old validation errors remain, new ones fail to show up. More information: I used a DALI version checked out on June 12 2007, 2330 hrs UTC. My workspace has a single simple JPA project and no other projects. This project has a single entity which is listed in the persistence.xml file. The persistence.xml path is: project/src/META-INF/persistence.xml Stack trace B java.lang.NullPointerException at org.eclipse.wst.common.internal.emf.resource.IDTranslator.setMOFValue(IDTranslator.java:45) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.primUpdateMOFFeature(EMF2DOMAdapterImpl.java:1399) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.updateMOFFeature(EMF2DOMAdapterImpl.java:1755) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.primUpdateMOF(EMF2DOMAdapterImpl.java:929) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.updateMOF(EMF2DOMAdapterImpl.java:909) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.primUpdateMOFMultiFeature(EMF2DOMAdapterImpl.java:457) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.updateMOFRootFeature(EMF2DOMAdapterImpl.java:950) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.primUpdateMOF(EMF2DOMAdapterImpl.java:925) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.updateMOF(EMF2DOMAdapterImpl.java:909) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer.doLoad(EMF2DOMRenderer.java:62) at org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl.basicDoLoad(TranslatorResourceImpl.java:142) at org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResourceImpl.doLoad(CompatibilityXMIResourceImpl.java:173) at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1354) at org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl.load(TranslatorResourceImpl.java:391) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:256) at org.eclipse.jem.internal.util.emf.workbench.ProjectResourceSetImpl.demandLoad(ProjectResourceSetImpl.java:83) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:271) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:398) at org.eclipse.jem.internal.util.emf.workbench.ProjectResourceSetImpl.getResource(ProjectResourceSetImpl.java:262) at org.eclipse.jpt.core.internal.content.persistence.PersistenceXmlJpaFileContentProvider.buildRootContent(PersistenceXmlJpaFileContentProvider.java:43) at org.eclipse.jpt.core.internal.JpaFileContentRegistry.buildContent(JpaFileContentRegistry.java:60) at org.eclipse.jpt.core.internal.JpaFileContentRegistry.getFile(JpaFileContentRegistry.java:44) at org.eclipse.jpt.core.internal.JpaProject.createJpaFile(JpaProject.java:613) at org.eclipse.jpt.core.internal.JpaProject$3.visit(JpaProject.java:480) at org.eclipse.core.internal.resources.Resource$1.visitElement(Resource.java:57) at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:81) at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:85) at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:85) at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:85) at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:126) at org.eclipse.core.internal.resources.Resource.accept(Resource.java:67) at org.eclipse.jpt.core.internal.JpaProject.fill(JpaProject.java:487) at org.eclipse.jpt.core.internal.JpaModelManager.createFilledJpaProject(JpaModelManager.java:208) at org.eclipse.jpt.core.internal.JpaModelManager$ResourceChangeProcessor.checkForProjectsBeingAddedOrRemoved(JpaModelManager.java:411) at org.eclipse.jpt.core.internal.JpaModelManager$ResourceChangeProcessor.checkForProjectsBeingAddedOrRemoved(JpaModelManager.java:434) at org.eclipse.jpt.core.internal.JpaModelManager$ResourceChangeProcessor.resourceChanged(JpaModelManager.java:327) at org.eclipse.jpt.core.internal.JpaModelManager$ResourceChangeListener.resourceChanged(JpaModelManager.java:284) at org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:282) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:276) at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:148) at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:311) at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1018) at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:45) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) STACK TRACE C java.lang.NullPointerException at org.eclipse.jpt.core.internal.platform.BaseJpaProjectContext.isValidPersistenceXmlLocation(BaseJpaProjectContext.java:98) at org.eclipse.jpt.core.internal.platform.BaseJpaProjectContext.sortPersistenceXmlFiles(BaseJpaProjectContext.java:79) at org.eclipse.jpt.core.internal.platform.BaseJpaProjectContext.initialize(BaseJpaProjectContext.java:73) at org.eclipse.jpt.core.internal.platform.BaseContext.refreshDefaults(BaseContext.java:50) at org.eclipse.jpt.core.internal.platform.BaseJpaProjectContext.refreshDefaults(BaseJpaProjectContext.java:145) at org.eclipse.jpt.core.internal.platform.BaseJpaProjectContext.refreshDefaults(BaseJpaProjectContext.java:141) at org.eclipse.jpt.core.internal.platform.BaseJpaPlatform.resynch(BaseJpaPlatform.java:201) at org.eclipse.jpt.core.internal.JpaProject$1.run(JpaProject.java:179) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
The user must restart the Workbench to get past the validation issue noted below if the below steps are followed. It does appear though that the project must to be closed and opened in the same Workbench session for items 3, 4, and 5 to occur, which would limit the exposure to this problem. We should investigate this issue for 1.0.1. The tip of the stack trace for the stack overflow: java.lang.StackOverflowError at java.io.FileOutputStream.writeBytes(Native Method) at java.io.FileOutputStream.write(FileOutputStream.java:260) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65) at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109) at java.io.PrintStream.write(PrintStream.java:412) at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336) at sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer(StreamEncoder.java:404) at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:115) at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:169) at java.io.PrintStream.write(PrintStream.java:459) at java.io.PrintStream.print(PrintStream.java:602) at org.eclipse.core.runtime.adaptor.EclipseLog.write(EclipseLog.java:551) at org.eclipse.core.runtime.adaptor.EclipseLog.writeln(EclipseLog.java:570) at org.eclipse.core.runtime.adaptor.EclipseLog.writeEntry(EclipseLog.java:494) at org.eclipse.core.runtime.adaptor.EclipseLog.writeLog(EclipseLog.java:472) at org.eclipse.core.runtime.adaptor.EclipseLog.log(EclipseLog.java:300) at org.eclipse.core.internal.runtime.PlatformLogWriter.logging(PlatformLogWriter.java:36) at org.eclipse.core.internal.runtime.RuntimeLog.log(RuntimeLog.java:95) at org.eclipse.core.internal.runtime.InternalPlatform.log(InternalPlatform.java:671) at org.eclipse.core.internal.runtime.Log.log(Log.java:56) at org.eclipse.wst.xml.core.internal.Logger._log(Logger.java:78) at org.eclipse.wst.xml.core.internal.Logger.logException(Logger.java:143) at org.eclipse.wst.xml.core.internal.document.DOMModelImpl.noChange(DOMModelImpl.java:621) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument._fireEvent(BasicStructuredDocument.java:515) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.fireStructuredDocumentEvent(BasicStructuredDocument.java:1173) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.internalReplaceText(BasicStructuredDocument.java:1950) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(BasicStructuredDocument.java:2394) at org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.replaceText(JobSafeStructuredDocument.java:84) at org.eclipse.wst.xml.core.internal.document.XMLModelUpdater.replaceSource(XMLModelUpdater.java:1608) at org.eclipse.wst.xml.core.internal.document.XMLModelUpdater.replaceChild(XMLModelUpdater.java:1566) at org.eclipse.wst.xml.core.internal.document.DOMModelImpl.childReplaced(DOMModelImpl.java:188) at org.eclipse.wst.xml.core.internal.document.NodeContainer.notifyChildReplaced(NodeContainer.java:357) at org.eclipse.wst.xml.core.internal.document.NodeContainer.removeChild(NodeContainer.java:401) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.removeDOMChild(EMF2DOMAdapterImpl.java:685) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.removeDOMChild(EMF2DOMAdapterImpl.java:671) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.primUpdateDOMMultiFeature(EMF2DOMAdapterImpl.java:374) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.updateDOMRootFeature(EMF2DOMAdapterImpl.java:940) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.primUpdateDOM(EMF2DOMAdapterImpl.java:916) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.notifyChangedForRoot(EMF2DOMAdapterImpl.java:1051) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.notifyChanged(EMF2DOMAdapterImpl.java:1012) at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:247) at org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1030) at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:367) at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:672) at org.eclipse.wst.common.internal.emf.resource.RootTranslator.setMOFValue(RootTranslator.java:34) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.primUpdateMOFMultiFeature(EMF2DOMAdapterImpl.java:436) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.updateMOFRootFeature(EMF2DOMAdapterImpl.java:952) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.primUpdateMOF(EMF2DOMAdapterImpl.java:927) at org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapterImpl.updateMOF(EMF2DOMAdapterImpl.java:911) at org.eclipse.wst.xml.core.internal.emf2xml.EMF2DOMSSEAdapter.notifyChanged(EMF2DOMSSEAdapter.java:224) at org.eclipse.wst.sse.core.internal.provisional.AbstractNotifier.notify(AbstractNotifier.java:201) at org.eclipse.wst.xml.core.internal.document.XMLModelNotifierImpl.notifyStructureChanged(XMLModelNotifierImpl.java:392) at org.eclipse.wst.xml.core.internal.document.XMLModelNotifierImpl.endChanging(XMLModelNotifierImpl.java:180) at org.eclipse.wst.xml.core.internal.document.DOMModelImpl.changedModel(DOMModelImpl.java:163) at org.eclipse.wst.sse.core.internal.model.AbstractStructuredModel$DocumentToModelNotifier.nodesReplaced(AbstractStructuredModel.java:152) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument._fireEvent(BasicStructuredDocument.java:602) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.fireStructuredDocumentEvent(BasicStructuredDocument.java:1201) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.internalReplaceText(BasicStructuredDocument.java:1970) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(BasicStructuredDocument.java:2394) at org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.replaceText(JobSafeStructuredDocument.java:84) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.set(BasicStructuredDocument.java:2908) at org.eclipse.core.internal.filebuffers.ResourceTextFileBuffer.handleFileContentChanged(ResourceTextFileBuffer.java:479) at org.eclipse.core.internal.filebuffers.ResourceFileBuffer.revert(ResourceFileBuffer.java:354) at org.eclipse.wst.sse.core.internal.FileBufferModelManager.revert(FileBufferModelManager.java:701) at org.eclipse.wst.sse.core.internal.model.ModelManagerImpl.revertModel(ModelManagerImpl.java:1408) at org.eclipse.wst.sse.core.internal.model.ModelManagerImpl.releaseFromEdit(ModelManagerImpl.java:1397) at org.eclipse.wst.sse.core.internal.model.ModelManagerImpl.releaseFromEdit(ModelManagerImpl.java:1345) at org.eclipse.wst.sse.core.internal.model.AbstractStructuredModel.releaseFromEdit(AbstractStructuredModel.java:1044) at org.eclipse.wst.xml.core.internal.document.DOMModelImpl.releaseFromEdit(DOMModelImpl.java:804) at org.eclipse.wst.xml.core.internal.emf2xml.EMF2DOMSSERenderer.modelChanged(EMF2DOMSSERenderer.java:382) at org.eclipse.wst.sse.core.internal.model.AbstractStructuredModel.fireModelChanged(AbstractStructuredModel.java:553) at org.eclipse.wst.sse.core.internal.model.AbstractStructuredModel.internalModelChanged(AbstractStructuredModel.java:887) at org.eclipse.wst.sse.core.internal.model.AbstractStructuredModel.changedModel(AbstractStructuredModel.java:382) at org.eclipse.wst.xml.core.internal.document.DOMModelImpl.changedModel(DOMModelImpl.java:167) at org.eclipse.wst.sse.core.internal.model.AbstractStructuredModel$DocumentToModelNotifier.nodesReplaced(AbstractStructuredModel.java:152) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument._fireEvent(BasicStructuredDocument.java:602) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.fireStructuredDocumentEvent(BasicStructuredDocument.java:1201) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.internalReplaceText(BasicStructuredDocument.java:1970) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(BasicStructuredDocument.java:2394) at org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.replaceText(JobSafeStructuredDocument.java:84) at org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.set(BasicStructuredDocument.java:2908) at org.eclipse.core.internal.filebuffers.ResourceTextFileBuffer.handleFileContentChanged(ResourceTextFileBuffer.java:479)
More info: The persistence.xml and orm.xml (this also affect orm.xml) that appear truncated after re-opening the project are actually still intact on the file system. If the user does not save these truncated versions and restarts the workbench, the files will return with their previous content.
*** Bug 194318 has been marked as a duplicate of this bug. ***
A little different scenario to reproduce the defect with the latest WTP , DALI and Eclipse updates (20.07.07): 1.Create EJB 3.0 project with JPA Facet 2.Create single entity class in the project (e.g. with one @Id field only) 3.Switch to another workspace and import the project from previos one (with copy) 4.The "No persistence.xml" problems appear, but if you open the persistence.xml it's ok 5.Delete the project (with content, from current workspace) and import it with copy again 6.The problem does not appear but the situation like in the attached sceenshot can be seen. - If you open the persistence.xml from "ejbModule" folder, it will be empty, if you open it from "Build" folder it will be "Ok"
Created attachment 74247 [details] Screenshot for Comment #4
I raise this as hotbug. This issue affects important use cases for SAP. We hope to have it fixed for 1.0.1.
Created attachment 77216 [details] A first look fix. Hope to help identify the problem
I have investigate the problem for a while and a have prepared a patch (just and idea), but the change is made in org.eclipse.wst.common.emf and because of that I do not like it very much. I do not know what else is effected. The general description of the problem as I understand it. The JpaModelManager has two listeners - facetedProjectListener, resourceChangeListener. This two listeners have the task to update the model as the projects and files are changed. When a resource is change a jpaProject is created and jpaProject.fill() is called. Filling the project means calling PersistenceXmlJpaFileContentProvider::buildRootContent(jpaFile). The following line located in buildRootContent() does the actual loading of the file PersistenceResource resource = (PersistenceResource) getResourceSet(resourceFile).getResource(fileURI, true); This line is successfully executed the first time the method is called for a fileURI. Loading the model includes reading and creating dom element and the corresponding EMF2DOM adapters.For every node and for its children an adapter is created. To create the adapter EMF2DOMAdapterImpl::createAdapter(Node node, Translator childMap) is called. The method delegates to EMF2DOMSSEAdapter::primGetExistingAdapter() which tries to find a cached adapter for the node. If the attached patch is applied then no existingAdapter is used and the adapters are created every time. The user will be able to close and open a project without exceptions thrown and without loosing the persistence.xml and orm.xml I will try to further investigate why are the existingAdapters causing the problem
Paul has been investigating this, assigning to him.
Copying some comments I made to Dimiter on the JPT mailing list: "Yes, this is one of the more annoying bugs we have. (We have a utility to generate unique project names for our JUnit tests, so we've worked around one of your issues that way.) Truth is, I know *when* it happens, but I really have no idea *why* it happens. It only happens when creating a resource with a given path (say "MyProject/src/META-INF/persistence.xml"), deleting or closing the project, and then attempting to recreate the resource with the same path. *Something* isn't being cleaned up or disposed, but again, I don't know what exactly. I've been experimenting with ArtifactEdits in an alt stream, and I've seen a disappearance of most or all of these issues, but again, I'm not sure why, and I'm not sure I understand the code well enough (lack of documentation is a big problem here) to feel good about introducing it into our maintenance stream. But that is what I'm going to look into doing. This bug is big enough that even some problems caused by (mis)use of ArtifactEdits are probable worth it. Incidentally, this issue won't crop up when importing a brand new project into a workspace. It only occurs when importing a project into a workspace in which it has been deleted in the same session (i.e. delete, then reimport.)" I'm currently waiting on some feedback from WTP developers. Hopefully that will help me resolve this issue ASAP.
Created attachment 77741 [details] proposed patch This patch looks pretty good so far to me. I've used the artifact edit framework, and there don't seem to be any major issues. Please test this out and let me know if there are any issues. We'd like to get this into our RC build.
Created attachment 77756 [details] proposed patch Slightly tweaked patch to fix a few minor problems. Overall, we did discover that *functionally* sometimes this fix is *not* an improvement over non-patched code. Sometimes, the orm and persistence models are not reloaded on project reopen/reimport. But the patch does seem to remove completely all exceptions, so we're going to go with this patch for the time being as an improvement and hope to fix the remaining issues post-RC. (committed patch for RC build)
Created attachment 77839 [details] patch addendum This looks to fix the problem uncovered by the previous bug fix. A race condition was addressed.
committed to post-RC code. (If downloading the RC, you should simply be able to use the patch addendum)
I have verified this fix myself, but since this is a hot bug, I thought the requester may want to verify as well. Please update the bug if you have any issues.
I think a colleague already verified it, but I will do it again with RC3.
I have verified the "steps to reproduce" from both the bug description and comment #4. They are OK with WTP 2.0.1 RC3.