Javax.persistence.PersistenceException:Invalid persistence.xml

I am a newbie of JPA and I'm working with JPA in Netbeans. I have an error on my persistence.xml file but I don't know how to solve it:

Error Msgs:
35940 [main] INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.6.6.Final
[2014-01-24 10:00:28,025] ERROR: Unable to prepare PXS
javax.persistence.PersistenceException: Invalid persistence.xml.
Error parsing XML (line-1 : column -1): cvc-elt.1: cannot find the declaration of element 'persistence'.
    at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:145)
    at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:169)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:317)
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
    at org.astri.ims.ccs.tps.persistence.TPSPersister.<init>(TPSPersister.java:119)
    at org.astri.ims.ccs.tps.persistence.TPSPersister.getInstance(TPSPersister.java:127)
    at org.astri.ims.ccs.pxs.necontrol.nce.NeControlEngine.prepare(NeControlEngine.java:109)
    at org.astri.ims.ccs.pxs.PXSComponent.prepare(PXSComponent.java:273)
    at org.astri.ims.ccs.CCSMain.prepareComponents(CCSMain.java:202)
    at org.astri.ims.ccs.CCSMain.startServer(CCSMain.java:446)
    at org.astri.ims.ccs.CCSMain.main(CCSMain.java:571)
[2014-01-24 10:00:28,027] ERROR: Failed to prepare the component:Proxy Services

I have tired to change the version from 2.1 to 2.0 as here said. However it's not work for me. Here's my persistence.xml file:

Persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://java.sun.com/xml/ns/persistence" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="Ent_ccserverPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.entitymodel.Clientassociation</class>
         a lots of entities here...
<class>org.entitymodel.Ipset</class>
<properties>
  <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/ims?zeroDateTimeBehavior=convertToNull"/>
  <property name="javax.persistence.jdbc.password" value="mypswd"/>
  <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
  <property name="javax.persistence.jdbc.user" value="root"/>
</properties>
  </persistence-unit>
</persistence>

I have tried changing my persistence.xml to :(as here mentioned.)

<?xml version="1.0" encoding="UTF-8"?>
<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">
  <persistence-unit name="Ent_ccserverPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>org.entitymodel.Clientassociation</class>
  Some entities here...
<class>org.entitymodel.Ipset</class>
<properties>
  <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/ims?zeroDateTimeBehavior=convertToNull"/>
  <property name="javax.persistence.jdbc.password" value="mypswd"/>
  <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
  <property name="javax.persistence.jdbc.user" value="root"/>
</properties>
  </persistence-unit>
</persistence>

But in vain.

My persistence.xml is produced by Netbeans, and I have tried build this file in another project and it was working fine, so I have no idea what's the problem.

Please help me. Thanks in advance!

Answers


Your missing the closing tags of the persistence XML file.

add

</persistence-unit>
</persistence>

to the end of the file and you should be good to go!.


Need Your Help

Ignite and Spring Boot

spring spring-boot gridgain ignite

How do I use Ignite with Spring Boot? I googled it but without success. Has anyone experience with the combination of Spring Boot and Ignite?