score:38
I fixed the problem the following way (I'm using RAD v8.5.1):
- Windows --> Preferences --> Validation
- Scroll down to "JPA Validator" and click on the Ellipses under Settings.
- Click on the "Add Include Group..." button.
- Click on the new Include Group that appeared to highlight it.
- Click on the "Add Rule..." button.
- A dialog menu pops up. Click the "Folder or file name" radio button and click on "Next".
- Click on "Browse Folder..." and navigate to your src directory (in my case, it was "src/main/resources") within your project (my project was a .war in a multi module app) in your workspace.
- Click on "Finish".
- Click on "OK". This will prompt a full build.
- The error will go away.
score:0
Whereabouts in your project structure is the file located?
For ref, I have mine in maven-module-name/src/main/resources/META-INF/
score:0
Hard to say since hard to reproduce (your persistence.xml
is perfectly valid) but maybe try to:
- Clean the project (both an "Project > Clean" and a Maven
clean
) - Force Eclipse to validate the XML file again (right-click, and select Validate XML file).
score:0
I've had the same problem on a few occasions and what worked for me was to copy the contents of the file, delete it and create a new persistence.xml file and paste the contents back in.
score:0
I came accross the same problem. Goto project properties -> Java build path -> source , remove */.java excluded attribute of src/main/resources source. Then add META-INF/persistence.xml. Then restart eclipse. You should persistence.xml under JPA Content in Project explorer. After that revert your changes.
Well, what I suggest seem stupid, but magically it works. By the way my eclipse version is 3.6.
score:0
The problem has been fixed in Indigo (released in June 2011), see https://bugs.eclipse.org/bugs/show_bug.cgi?id=251323#c24 and https://issues.sonatype.org/browse/MECLIPSEWTP-11.
The "persistence.xml file does not have recognized content." error might still appear, randomly, on project import or Workspace startup, but it can be fixed with a project clean or maven project update. This will be fixed in Dali in SR2.
score:0
I had the same problem, to make it go away I had to make sure this line was the very first line at the top of the file (with no leading empty lines or spaces):
<?xml version="1.0" encoding="UTF-8"?>
score:0
I had the same error, but solved it in a different way.
The thing is that META-INF must be considered a source folder, and as it was under /ejbModule (mine is a EJB project) I assumed it was on the build path. And it wasn't. Actually it was on "exclude" list on build path. So, all I did was right-click the META-INF folder on Project Explorer view and selected INCLUDE on Build Path menu. Then I asked Eclipse to clean the project and everything was right again.
Best Regards.
score:0
I've had the same problem. My solution: right click on the persistence.xml file -> JPA-Tools -> Synchronize Class List. After that it was resolved.
score:0
In my case it was the Maven plugin which has a bug that sets "Exclude" to . in the Build path for your resources folder. Removing . solved the issue for me
score:0
I got it fixed by dragging META-INF folder to src/main/resources and drag it back to src/test/resources. Thats all it took for me to fix the issue. I tried above given all steps but none of those seem to be working for me and finally this one done the trick.
score:0
just solved the issue by doing this:
- in schemaLocation, i deleted "h ttp://java.sun.com/xml/ns/persistence/" making it:
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.
score:0
Ok ... another rather robust solution that worked for me since the top-most ones did not:
since I used Mercurial and could go back easily without any notable differences in the current and last versions it worked this way:
(committed some important changes rather unrelated to this problem)
- switching to previous repo version
- (auto-/refresh/-rebuild ran fine)
What I recognized was, that the problem may have been due to the fact that the Java Builder did not generate my war/WEB-INF/classes/
files. The following did not work to follow this trail in letting it build my project:
- disabling/reconfiguring Validators, Builders, Facets (till only the Java Builder/Facet was there)
- renaming the
persistence.xml
or editing it in various ways
which did not help it as if some internal state could not be changed.
score:0
For me it worked once I have cleared all messages from Markers tab in eclipse
score:0
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.
score:1
I got the issue fixed by creating a "symbolic link" in Eclipse. So, my persistence.xml file remains in src/main/resources/META-INF as Maven expects and m2eclipse requires. However, in order to fix the Dali issues, create a new file in src/main/java/META-INF that links to the one in src/main/resources/META-INF. You do this by hitting the "Advanced" options when creating the new file and locating the file using the "Browse..." button. Note that this will not create a physical file in the META-INF folder, however, you need the folder itself in order to create the link.
Hope that works for you.
score:1
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:
- List item Select menu item Project > Properties > Preferences > Validation
- List item Disable the JPA Validator for both Manual validation and Build validation.
You might need to clean and rebuild. Your mileage may vary.
score:2
I fixed this by going to Project - Properties - Java Persistence: and then setting the "Source Folder" in the "Canonical metamodel (JPA 2.0)" section to: "src/generated/resources"
score:2
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.
score:2
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.
score:2
This problems occurs if you
- Convert a JPA project to a Maven project or
- Add the JPA facet to a Maven project.
The solution is
- Select Windows > Preferences > Validation
- Disable the JPA Validator for both Manual validation and Build validation
After changing these settings,then clean your project.
score:2
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.
score:5
The bug has reappeared for certain Indigo (3.7) versions. See here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=357810
Right-click project -> Maven -> Update Project Configuration...
This might destroy certain buildpath entries and/or the deployment assembly, very annoying, so only do this when changing Maven deps.
To workaround the persistence.xml message until the patch is released, you need to clean the project on many operations as even setting the error level to "ignore" doesn't work. This is a complete bummer.
score:8
Turning this error into a warning may make the problem go away, but it will not fix the underlying problem with the Eclipse Dali plugin. It will also mean the extremely useful JPA Structure and JPA Details views will not work.
The link offered by OP and the approach of most of the answers here are actually meant to get around a different problem wherein Maven wants to filter the persistence.xml file and thus tells Eclipse to ignore it. A viable work-around for that problem is explained here and involves removing the exclused: '**' from the src/main/resources entry in the classpath in the project properties.
Back to the OP's original question, I had this EXACT same error message (which in and off itself tells you that the persistence.xml file has been located). For me the solution was to change the persistence XML element from this:
<persistence 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_1_0.xsd"
version="1.0">
to this:
<persistence 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"
version="2.0">
Once changed, the error went away and Dali instantly came alive and now everything Just Works. Hope this helps somebody someday.
score:14
I figured out what the problem is here.... the JPA Facet is assuming that the META-INF folder is directly under a source folder. If you are using a Maven project, you likely have something like src/main/resources or src/test/resources. If your persistence.xml is under these folders it will complain. If you create a new source folder (call it "jpa") and create a META-INF/persistence.xml in there, then it will find it successfully. (I also had to do a clean/close/open project)
This is certainly a pain.... and I can see many situations this won't work well.
score:14
I had this same problem in Eclipse 3.6 (Helios). The cause was the JPA Facet was set to JPA Version 1.0, however my persistence.xml file was specifying JPA Version 2. So I changed the JPA Facet to version 2.0 and the problem went away. (Project --> Properties --> Project Facets --> "Configuration" drop down --> set this to "Minimal JPA 2.0 configuration"
score:17
<persistence 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"
version="2.0">
Worked for me!
score:33
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.
Source: stackoverflow.com
Related Query
- Eclipse does not recognize content of persistence.xml
- Eclipse does not recognize static web content under src/main/resources/static
- Android: Eclipse autocomplete does not work in xml files
- Eclipse does not recognize org.jdesktop.*
- PyDev in Eclipse does not recognize db.add_column from South
- Eclipse does not recognize existing resolved Maven dependencies
- Eclipse debugger does not recognize new java code
- Eclipse Android XML content assist not working
- Eclipse CDT Indexer does not fully recognize c++11
- Eclipse Does Not Recognize JRE 8 as Greater Than JRE 5
- Why does Eclipse not recognize the build() method from the Notification.Builder class to return a Notification object?
- Content assist in Eclipse does not work for EL in JSP files
- Eclipse project does not recognize Swagger Codegen artefacts
- Eclipse does not recognize gradle dependencies
- Content assist (Ctrl-Space) in does not work in Eclipse in Debian Gnome running in VMWare for Windows
- Eclipse does not recognize environment variables
- Eclipse does not recognize package Import? JOGL
- Content assistant / autocomplete not available anymore in Eclipse for Android XML files
- Eclipse does not recognize some valid attributes and tags
- eclipse does not recognize package
- Eclipse Mars integration with WAS Liberty server 8.5.5.6 does not recognize some Java EE 6 installed features
- Why does Eclipse not recognize my Nexus 7?
- android XML view Does not display ToggleButton in Eclipse
- Ternary operator does not recognize compile error in Eclipse
- Java: Eclipse does not recognize the source folder
- content assist does not work in Eclipse
- New Eclipse workspace in working copy folder does not recognize existing projects from subversion
- Eclipse does not recognize Message Bundle (f:loadBundle error)
- Eclipse Juno project facets does not recognize that I have Java 1.6
- Trying to run an xslt for xml with eclipse but it does not work
More Query from same tag
- how do I get eclipse to use a different compiler version for Java?
- Ant build in Eclipse failing: Unable to understand the error from console
- In Eclipse CDT shared resource folder that is built differently for the project
- Put Sql Data to a Number Array
- Enforcing java 6 source compatibility in maven and/or eclipse
- Failed project transformation from external jars to maven
- Compress/uncompress data in memory
- Eclipse CDT on Snow Leopard cannot find binaries
- Inline comments in Java: /** opposed to /*?
- Eclipse: Import "Existing Maven Projects" create EAR project automatically
- Swagger UI - Unable to infer base url in Swagger 2.9.2
- Simple web project deploys on Tomcat 6, not on JBoss 6
- local variable referenced before assignment in strange condition
- Exception in thread "main" java.lang.NoClassDefFoundError: MyFile Caused by: java.lang.ClassNotFoundException:
- FXML file causes the app to not open up
- Showing small popup when I assigned shortcut key to menu
- Can't Install ADT. org.eclipse.wst.xml.ui is missing
- Doing networkprocesses on the Main UI
- Importing HBC library
- Hibernate tools: persistence unit not found
- Eclipse plugin development: How to access the default editor?
- "Selection does not contain a main type" error when running JavaFX in eclipse.
- Problem Setting VM Arguments with Eclipse 3.5.2
- Using Jmockit with Eclemma
- JBoss Server Not Starting From Eclipse and Commandline
- How do you connect an eclipse to a WebSphere Application server hosted on remote server?
- Console view is empty in Eclipse with Maven 3.5.0
- app won't install after package rename
- Rearrange docs in Eclipse IDE
- How to add traces in a non-intrusive way in a Java program in Eclipse