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 e
I had src/main/java/META-INF/persistence.xml
working fine in Eclipse with embedded Tomcat. Because it was not being copied into the Maven-built WAR, I moved it to src/main/resources/META-INF
.
Now src/main/resources/META-INF/persistence.xml
won't validate.
If rename to xyz_persistence.xml, it validates fine.
If rename to persistence.xml, it fails to validate.
When these annoying situations arise, I often find numerous different "solutions" like mine, most of which are not universally applicable.
So, here's my "solution", which I think it a hack to get around a bug:
To remove the error "persistence.xml file does not have recognized content" error, disable the JPA Validator:
You might need to clean and rebuild. Your mileage may vary.
Had same problem with error
The persistence.xml file does not have recognized content
Fixed by editing file in eclipse, any edit will do. And after saving error got away.
just solved the issue by doing this:
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd"
i added <?xml version="1.0" encoding="UTF-8"?>
at the top.
i clean build the project. error's gone.
i added the "h ttp://java.sun.com/xml/ns/persistence/" again:
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
i clean build the project. error's not there.
i deleted <?xml version="1.0" encoding="UTF-8"?>
at the top.
i clean build the project. error's still not there.
hope this helps someone in the future.
I am using eclipse mars and had this same exact error. What I had to do was 1 set the version of jpa for the project facet. right click project -> Properties -> Project Facets
Set version of jpa to 2.1 in my case.
Note: Just configuring the jpa project facet will not remove the error. You also need to configure the platform.
Next I had to configure the JPA platform. right click project -> Properties -> JPA
. Change platoform to be Hibernate 2.1 in my case.
This problem also manifests itself when you open the persistence.xml with the Persistence XML Editor and you only have a single Source
tab at the bottom and not the other tabs for General, Connection, Options, Properties etc.
Any updates on this? This is still an issue it seems right? If I create a JPA project, convert to Maven project, the error appears and I can't get rid of it with any of the recommended methods.
Edit
Ok so after maneuvering some folders around so its in an actual Maven directory format, it still didn't work - but creating a linked folder under src/main/java
named META-INF, linked to src/main/resources/META-INF
it was resolved.
Creating a Maven project and adding the JPA facet works also, but only because the JPA facet adds the META-INF and persistence.xml file to src/main/java
which I don't think is exactly right.
No Need to change andthing in your xml file and no need to add xml in src folder. Put your persistance.xml file in META-INF folder and then put META-INF src/main/resource folder.
Try following approach:
Right click on project> Java Build path > Source Tab > ProjectName/src/main/resource > set Included(All) and Excluded(None).
then clean and build your project. It will work for you. Tried this approach on RAD 7 & 8..5 & Eclipse.