Remove deprecation from Configuration until after new metamodel completely in place


Decided to leave in place for Ejb3Configuration since JPA bootstrapping was always the recommended and supported mechanism for JPA use cases.




Steve Ebersole
August 30, 2011, 1:39 AM

The work for was committed as part of

Vladimir Nicolici
March 30, 2012, 3:42 PM

Can you also remove the deprecation from the Configuration.buildSessionFactory() method? It's very annoying, and I lost a few hours searching for the proper way to do it, and I still didn't find it. This, for example, doesn't work:

ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder();
ServiceRegistry serviceRegistry = serviceRegistryBuilder.buildServiceRegistry();
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);

It gives this error:

WARN: HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
Exception in thread "main" org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set

Anyway, it's even worse when I try to use the deprecated way, I'm not even able to read the configuration:

Configuration configuration = new Configuration();

gives this error:

ERROR: HHH000197: Error parsing XML: hibernate-connection.cfg.xml(3) Document is invalid: no grammar found.
Mar 30, 2012 4:19:32 PM org.hibernate.internal.util.xml.XMLHelper$ErrorLogger error
ERROR: HHH000197: Error parsing XML: hibernate-connection.cfg.xml(3) Document root element "hibernate-configuration", must match DOCTYPE root "null".
Exception in thread "main" org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(
at org.hibernate.cfg.Configuration.configure(
at DbTest.main(
Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 25; Document is invalid: no grammar found.

Even a nearly empty configuration file, like below, causes the same error:

<?xml version='1.0' encoding='utf-8'?>

xsi:schemaLocation=" hibernate-configuration-4.0.xsd"




Not sure if relevant, but does not really exist, attempting to access it using a browser gives this:

Sorry, the page you're looking for cannot be found.
Please use the Search box in the header to check that the information isn't located somewhere else.

Even the example configuration file from

gives me the same error about invalid XML grammar.

Anyway, my main issue is that the documentation still recommends the use of the deprecated method, and no alternate method is documented (or I can't find it), see:

Other people have the same issue:

Please note that I have about 3 years experience in using hibernate in various projects, and never had such issues until trying to use the latest version in a new project, so do not dismiss this comment as a newbie question.

I'm using Hibernate 4.1.1 in a simple "hello world" project, JDK 1.7.0_03, Eclipse Indigo SR2.

Vladimir Nicolici
April 2, 2012, 10:31 AM

After further investigation, it seems the only way to configure Hibernate 4.1.1 and obtain a working SessionFactory is to use Hibernate 3 DTD based configuration files instead of the Hibernate 4 XSD configuration files, and to use the deprecated buildSessionFactory() method instead of the recommended buildSessionFactory(serviceRegistry) method.

I found this by running the annotations example from the tutorials ( The tutorial samples still use the deprecated method, that's why they still work.

Paul Benedict
April 9, 2014, 4:17 PM

I think we should spin off a new ticket for the "Document is invalid: no grammar found" SAX error. I am using 4.2.9 and cannot find any solution except to dump using the XSD (and revert to the DTD). Others on the internet come to the same conclusion.


Steve Ebersole


Steve Ebersole

Fix versions






Suitable for new contributors


Requires Release Note


Pull Request