Whenever I\'m disconnected from the internet, I get the following exception:
org.hibernate.HibernateException: Could not parse configuration: com/mashlife/re
instead of
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
use
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
it worked fine for me
You can use an internal DTD (not pretty IMO) or download the DTD file to your filesystem.
Check W3Schools' for more information: http://www.w3schools.com/dtd/dtd_intro.asp
In your mapping files, you must have the exactly SAME doctype as found in the mapping DTD's.
Then and only then you'll see that the dtd's found in hibernate3.jar can be found through the classpath, and running behind a firewall, stand-alone, etc. will be no problem at all. No local dtd's in your projects to solve this issue, no code to intercept. :-)
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
The same is of course applicable for the configuration file.
It is not possible because, hibernate jar files is also load the some dtd content but slow internet connection it is worked.
(1) Hibernate Configuration File Location
The first solution was to provide the DTD file location in the system using classpath. So the DocType that worked offline would be;
<!DOCTYPE hibernate-configuration SYSTEM
"classpath://org/hibernate/hibernate-configuration-3.0.dtd">
(2)Use SourceForge DTD URL with SYSTEM
Another solution I found working is when I change the DTD URL to SourceForge and changed the declaration from PUBLIC to SYSTEM.
So below will also work if your system is offline.
<!DOCTYPE hibernate-configuration SYSTEM
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
Hibernate Work Offline
In case this helps anyone else ... my problem was that I was including the wrong Maven artifact. I was including spring-hibernate3
:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-hibernate3</artifactId>
<version>2.0.8</version>
</dependency>
Replacing it with spring-orm
fixed this issue:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>2.5.6.SEC03</version>
</dependency>
Hibernate can resolve the DTDs locally (without a network connection).
Your DOCTYPE is using the new namespace (http://www.hibernate.org/dtd/) for Hibernate 3.6, so you might have an older version of the Hibernate libraries in your classpath.
I experienced the same issue after upgrading to Hibernate 3.6.8.Final. I had multiple versions of hibernate3.jar on the classpath causing an old incompatible version of the DTD Entity Resolver to be loaded which only works with the old namespace (http://hibernate.sourceforge.net/). For reference, here's a link to the newer DTD Entity Resolver.
I'm using hibernate3-maven-plugin which has a transitive dependency on an older version of Hibernate so I just had to specify a plugin dependency on Hibernate 3.6.8.Final.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
...
</configuration>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.8.Final</version>
</dependency>
</dependencies>
</plugin>