Hibernate fails to read DTD intermittently


#1

We have recently upgraded to 4.1.7 and are experiencing issue time to time (very intermittently) on initializing SessionFactory because of unable to read DTD remotely.

Configuration configuration = new Configuration().configure();
			ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()). buildServiceRegistry();
			sessionFactory = configuration.buildSessionFactory(serviceRegistry);

If we switch to referencing locally, all works well.

<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

To

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration SYSTEM 
    "classpath://org/hibernate/hibernate-configuration-3.0.dtd">



We don’t this this is due to network. We are able to reference all other schema references when this one fails

Any help will be appreciated.


#2

This is how the DTD looks like in Hibernate 5.

<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

Now, you can also use a local DTD, if that works faster for you. Just update your HBM files and hibernate.cfg.xml to reference the local one.


#3

Thanks Vlad for your quick reply.