Reputation: 114817
I'm taking my first steps with JPA (Hibernate). The overall idea is to connect to a legacy database to do complex queries. I think, hibernate is a great companion for this task, but...
... for a start, I created one bean, the persistence.xml and hibernate.cfg.xml configuration files and some lines of code in a main method, starting with:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("foo");
It reads the persistence.xml file but, because I'm disconnected from the internet, it can't read the schema file (xsd) to validate persistence.xml and complains with exceptions. (And I don't have a local copy of persistence.xsd in that environment). I tried with removing the schemalocation attribute, but that didn't help. No grammar, no JPA!?
Is there a way / a trick / a workaround to disable document validation at least for parsing persistence.xml?
Upvotes: 3
Views: 3293
Reputation: 33783
Extracted from JPA specification
The container/presistence provider (Hibernate) must validate the persistence.xml file against the persistence_1_0.xsd schema and report any validation errors
...
Persistence configuration files must indicate the persistence schema by using the persistence namespace
http://java.sun.com/xml/ns/persistence
And indicate the version of the schema by using the version element as shown below
<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">
The element shown above is valid for JPA 1.0 Update to 2.0 if you are using JPA 2.0
Upvotes: 4