0

I am getting below error :org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 77; schema_reference.4: Failed to read schema document 'http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not xsd:schema. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) My Persistence.xml counts like below :

 <persistence xmlns="http://xmlns.jcp.org/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" version="2.1">

<persistence-unit name="jpa-metaservice"
    transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

    <properties>
        <!-- Configuring JDBC properties -->
        <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@host:1575:sid" />
        <property name="javax.persistence.jdbc.user" value="username" />
        <property name="javax.persistence.jdbc.password" value="password" />
        <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver" />

        <!-- Hibernate properties -->
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.format_sql" value="true" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect" />
        <property name="hibernate.hbm2ddl.auto" value="none" />

        <!-- Configuring Connection Pool -->
        <property name="hibernate.c3p0.min_size" value="5" />
        <property name="hibernate.c3p0.max_size" value="20" />
        <property name="hibernate.c3p0.timeout" value="500" />
        <property name="hibernate.c3p0.max_statements" value="50" />
        <property name="hibernate.c3p0.idle_test_period" value="2000" />
        <class>com.db.solrSearchSvc.model.ModelObjectsorm</class>
        <class>com.db.solrSearchSvc.model.ModelObjectField</class>
        <class>com.db.solrSearchSvc.model.SolrCustomer</class>
    </properties>
</persistence-unit>
4
  • Caused by: java.net.UnknownHostException: xmlns.jcp.org at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) ... 49 more : Line 5 in XML document from URL [file:/C:/Users/1002190/Documents/eclipseWorkspace/sam1/astra-advsearch-services/target/classes/persistence.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 5; columnNumber: 28; cvc-elt.1: Cannot find the declaration of element 'persistence' Commented Jan 12, 2021 at 6:19
  • I am using Spring -Boot 2.3.3.RELEASE on Tomcat 9. Kindly help with persistence.xml schema location so that I could come over this issue . Commented Jan 12, 2021 at 6:20
  • Caused by: org.xml.sax.SAXParseException; systemId: http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd; lineNumber: 1; columnNumber: 1; Premature end of file.' Commented Jan 12, 2021 at 8:19
  • Could you please provide full stack trace and and full persistence.xml file. Commented Jan 12, 2021 at 8:28

1 Answer 1

0

you should add below dependency to your pom:

<dependency>
        <groupId>dom4j</groupId>
        <artifactId>dom4j</artifactId>
        <version>1.6.1</version>
</dependency>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.