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.