For my projects Necessity i regroup all the persistence.xml entries in one core project which i bind as maven dependency wherever i need.
The problem is that the eclipse
I assume it is the JPA perspective that you have configred.
I just created an "empty" persistence.xml in src/main/java/META-INF. It would be seen by maven, so never gets further...It's a hack, I know, but it works...
I got rid of this by disabling the JPA facet for my Java project.
Thanks to sionnach733 who put me on the right way
If this error occurs on a Maven project that does not require the JPA facet, you can tell m2e not to apply the JPA activation (essentially, not to add the JPA facet during project configuration) by setting the following property in the pom.xml of the affected project:
<properties>
<m2e.jpa.activation>false</m2e.jpa.activation>
</properties>
If you press CTRL-SPACE
within an existing <properties>
tag, in the pom.xml source, content-assist will provide a shortcut to create the property, so you don't really have to remember the syntax, just that the content assist is there... ;)
After applying the property make sure to run Maven -> Update Project (Alt-F5)
on the project in question. You may have to remove the JPA facet from the affected project manually once, by using the Project Properties page.
For those who wonder why m2e thinks the JPA facet needs to be added in the first place: This is handled by a JpaProjectConfigurator
class in the m2e/WTP eclipse plugin, and can be customized by implementing factet detectors (which all must extend the AbstractFacetDetector
class and registering them at the org.eclipse.m2e.wtp.facetDetectors
extension point). So the facet may get activated by a plugin you've installed, or by the default detection built into the Eclipse m2e/WTP feature, which basically looks for an existing persistence.xml
or orm.xml
file or a JPA provider library in the projects' classpath. I had this happen when a business logic artifact was depending depending on my persistence layer artifact (with workspace resolution turned on, which may be part of the problem) that had a META-INF/persistence.xml
, but the business logic artifact didn't.
For details, see M2E-WTP/New and Noteworthy/1.0.0 and The rg.eclipse.m2e.wtp.jpa.internal.configurators.JpaProjectConfigurator source code.
IMHO the accepted answer is no good advice, as it is wrong to just set the error severity to "Ignore", since then Eclipse won't warn on projects that are indeed JPA projects and thus have/need the JPA facet and consequentially should provide a persistence.xml
in the expected location (naming and location can be important for artifacts deployed in Java EE environments).
In addition by actually configuring a non-JPA project correctly (i. e. without the superfluous JPA facet), Eclipse won't waste time running JPA validation and JPA change monitoring on the project. You might have noticed JPA Project Change Event Handler (waiting)
in the Progress view a lot (especially when having multiple JPA projects in the workspace). These no longer run for projects that don't require JPA, when the JPA facet is removed.
Window->Preferences->Java Persistence-> JPA-> Errors/warnings-> Project
Then change it from error to whatever you like(warning/info/ignore). You could also choose configure project specific settings if you don't want it to affect other projects
1. go to .setting directory of the project
2. modify org.eclipse.wst.common.project.facet.core.xml
remove the following:
<installed facet="jpt.jpa" version="2.0"/>
3. Refresh the project
Cheers!!!