Eclipse does not recognize content of persistence.xml

Viewed 84950

Im getting the following error in eclipse:

The persistence.xml file does not have recognized content.

My persistence.xml file works great in my application but eclipse keeps giving me this error. I got this after moving the file and updating my project configuration with m2eclipse. I did not change the file itself. Anyone knows how to solve this?

persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="localDB" transaction-type="RESOURCE_LOCAL">

        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <class>package.Users</class>
        <properties>
            <!-- enable warnings for debugging -->
            <property name="openjpa.Log" value="DefaultLevel=TRACE, Runtime=INFO, Tool=INFO, SQL=TRACE"/>
            <!-- connection properties -->
            <property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost/test"/>
            <property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
            <property name="openjpa.ConnectionUserName" value="root"/>
            <property name="openjpa.ConnectionPassword" value=""/>

        </properties>
    </persistence-unit>
</persistence>

Update

Looks like a bug in m2eclipse in combination with jpa.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=251323

Temporarily solved by setting the option to show it as a warning instead of an error

28 Answers

For me it worked once I have cleared all messages from Markers tab in eclipse

Add your JPA Version to the Project Facets to remove this error.

In my case i have used JPA 2.2 but in Project Facets JPA 1.0 was specified. After fixing this, the error disappeared.

Related