Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 370156 - NPE when moving persistence.xml
Summary: NPE when moving persistence.xml
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Libra (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Kaloyan Raev CLA
QA Contact: Kaloyan Raev CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-30 14:47 EST by Zina Mostafia CLA
Modified: 2022-02-24 11:24 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zina Mostafia CLA 2012-01-30 14:47:02 EST
I have a web project that has the JPA facet too.
By default the persistence.xml is created in the src/META-INF folder of the project.
I am using the latest eclipse 372
I have the free OSGI tools that I am using to add the OSGi facet to the project.
As part of the facetInstallDelegate, it tries to move the persistence.xml to the same location as the MANIFEST.MF which is in this case inside the webContent/META-INF folder.

The move of the file succeeds, but right after I get this NPE

java.lang.NullPointerException
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXml.registerRootStructureNode(GenericPersistenceXml.java:219)
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXml.update(GenericPersistenceXml.java:115)
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericRootContextNode.syncPersistenceXml(GenericRootContextNode.java:123)
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericRootContextNode.updatePersistenceXml(GenericRootContextNode.java:157)
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericRootContextNode.update(GenericRootContextNode.java:73)
	at org.eclipse.jpt.jpa.core.internal.AbstractJpaProject.update(AbstractJpaProject.java:1898)
	at org.eclipse.jpt.jpa.core.GenericJpaProjectManager$2.execute(GenericJpaProjectManager.java:452)
	at org.eclipse.jpt.common.core.internal.utility.JobSynchronizer$SynchronizationJob.run(JobSynchronizer.java:160)
	at org.eclipse.jpt.common.core.internal.utility.CallbackJobSynchronizer$CallbackSynchronizationJob.run(CallbackJobSynchronizer.java:137)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


Is there certain expectations that this file has to be in the src folder ?
Comment 1 Zina Mostafia CLA 2012-01-30 14:48:13 EST
I do not see this problem when using Eclipse 362.
Comment 2 Neil Hauge CLA 2012-01-31 10:04:18 EST
Sounds like a possible regression.  I'll investigate.
Comment 3 Neil Hauge CLA 2012-02-01 13:25:26 EST
I'm unable to get as far as you are getting.  The addition of the OSGi Bundle Facet fails for me with the following exception.  Not sure if our configuration is different, but I just have a default Dynamic Web Project with JPA Facet.

org.eclipse.core.internal.resources.ResourceException: Resource '/WebProj/META-INF' does not exist.
	at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:320)
	at org.eclipse.core.internal.resources.Resource.checkMoveRequirements(Resource.java:391)
	at org.eclipse.core.internal.resources.Resource.assertMoveRequirements(Resource.java:185)
	at org.eclipse.core.internal.resources.Resource.move(Resource.java:1579)
	at org.eclipse.core.internal.resources.Resource.move(Resource.java:1559)
	at org.eclipse.libra.facet.OSGiBundleFacetInstallDelegate.moveMetaInfToRoot(OSGiBundleFacetInstallDelegate.java:357)
	at org.eclipse.libra.facet.OSGiBundleFacetInstallDelegate.doExecute(OSGiBundleFacetInstallDelegate.java:87)
	at org.eclipse.libra.facet.OSGiBundleFacetInstallDelegate.execute(OSGiBundleFacetInstallDelegate.java:76)
	at org.eclipse.wst.common.project.facet.core.internal.FacetedProject.callDelegate(FacetedProject.java:1477)

It appears to be looking for a meta-inf folder at the root, which does not exist.  Not sure if they expect it to be there, are were unable to create it.  What version of libra are you using?  I am using 1.1.x.

Adding Kaloyan.  Perhaps this is a Libra issue.
Comment 4 Neil Hauge CLA 2012-02-01 13:27:54 EST
As a side note, adding the OSGi bundle facet to a simple JPA project works fine.  Resources are moved as expected and things work fine afterwards.
Comment 5 Neil Hauge CLA 2012-02-03 11:40:48 EST
Reassigning to Libra since this looks more like a Libra issue from my testing.
Comment 6 Adrian Padilla CLA 2013-05-21 11:59:44 EDT
I was able to see a very similar issue as the one reported here, Web+JPA project, then converted to OSGi, result is NPE in GenericPersistenceXml.java:260

java.lang.NullPointerException
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXml.unregisterRootStructureNode(GenericPersistenceXml.java:260)
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXml.syncPersistence(GenericPersistenceXml.java:124)
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXml.updatePersistence(GenericPersistenceXml.java:97)
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXml.update(GenericPersistenceXml.java:93)
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericRootContextNode.syncPersistenceXml(GenericRootContextNode.java:127)
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericRootContextNode.updatePersistenceXml(GenericRootContextNode.java:161)
	at org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericRootContextNode.update(GenericRootContextNode.java:77)
	at org.eclipse.jpt.jpa.core.internal.AbstractJpaProject.update(AbstractJpaProject.java:2036)
	at org.eclipse.jpt.jpa.core.internal.AbstractJpaProject$UpdateJobCommand.execute(AbstractJpaProject.java:2023)
	at org.eclipse.jpt.common.core.internal.utility.command.RepeatingJobCommandWrapper.executeCommand(RepeatingJobCommandWrapper.java:207)
	at org.eclipse.jpt.common.core.internal.utility.command.NotifyingRepeatingJobCommandWrapper.executeCommand(NotifyingRepeatingJobCommandWrapper.java:69)
	at org.eclipse.jpt.common.core.internal.utility.command.RepeatingJobCommandWrapper.execute_(RepeatingJobCommandWrapper.java:192)
	at org.eclipse.jpt.common.core.internal.utility.command.RepeatingJobCommandWrapper$StartJobCommand.execute(RepeatingJobCommandWrapper.java:172)
	at org.eclipse.jpt.jpa.core.internal.InternalJpaProjectManager.execute_(InternalJpaProjectManager.java:1120)
	at org.eclipse.jpt.jpa.core.internal.InternalJpaProjectManager$ClientJobCommandWrapper.execute(InternalJpaProjectManager.java:1100)
	at org.eclipse.jpt.common.core.internal.utility.command.JobCommandJob.run(JobCommandJob.java:42)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)