0

Have put the persistence.xml in the classpath of the project in eclipse because before the error was that the file was not found. Now gives this error:

Caused by: javax.persistence.PersistenceException: Invalid persistence.xml. Error parsing XML [line : -1, column : -1] : cvc-elt.1: Can not find the declaration of element 'persistence'

enter image description here

here is my file:

<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="2.1"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="DataSource" transaction-type="JTA">
        <description>JTA persistence unit related to the datasource DataSource</description>
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="hibernate.ejb.cfgfile" value="hibernate_DataSource.cfg.xml"/>
        </properties>
    </persistence-unit>

    <persistence-unit name="securityStore" transaction-type="JTA">
        <description>JTA persistence unit related to the datasource securityStore</description>
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
           <property name="hibernate.ejb.cfgfile" value="hibernate_securityStore.cfg.xml"/>
        </properties>
    </persistence-unit>
</persistence>
SternK
  • 11,649
  • 22
  • 32
  • 46
  • Does this answer your question? [Can not find the declaration of element 'persistence'](https://stackoverflow.com/questions/20818737/can-not-find-the-declaration-of-element-persistence) – SternK Feb 15 '21 at 18:04
  • Hello, no it does not.. – daly mohamed Feb 16 '21 at 08:53

1 Answers1

0

According to the JPA spec (see section 8.2.1 persistence.xml file):

A persistence.xml file defines a persistence unit. The persistence.xml file is located in the META-INF directory of the root of the persistence unit.

So, try to put your persistence.xml in the META-INF directory.

P.S. Maybe you application actually use not the persistence.xml what you expect, but placed somewhere in the classpath in META-INF directory.

SternK
  • 11,649
  • 22
  • 32
  • 46
  • in fact , I'm working with Ireport 3.0.0 , i'm having dificulties in parsing my persistence.xml file wich works with jpa 2.1 version (hibernate 5.1.14-final)..so my question is does ireport 3.0.0 supports jpa 2.1.if not , any further solution? – daly mohamed Feb 16 '21 at 23:16
  • Hello community, I'm working with Ireport 3.0.0 , i'm having dificulties in parsing my persistence.xml file wich works with jpa 2.1 version (hibernate 5.1.14-final)..so my question is does ireport 3.0.0 supports jpa 2.1.if not , any further solution? – daly mohamed Feb 16 '21 at 23:17