[
https://hibernate.onjira.com/browse/HHH-6617?page=com.atlassian.jira.plug...
]
Vladimir Nicolici commented on HHH-6617:
----------------------------------------
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();
serviceRegistryBuilder.configure("hibernate-connection.cfg.xml");
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();
configuration.configure("hibernate-connection.cfg.xml");
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(Configuration.java:2008)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1925)
at DbTest.main(DbTest.java:14)
Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 25; Document is
invalid: no grammar found.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
Even a nearly empty configuration file, like below, causes the same error:
<?xml version='1.0' encoding='utf-8'?>
<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configura...
hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<session-factory>
</session-factory>
</hibernate-configuration>
Not sure if relevant, but
http://www.hibernate.org/xsd/hibernate-configuration 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
http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html/ch01.html#d5e83
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:
http://docs.jboss.org/hibernate/orm/4.1/quickstart/en-US/html/ch02.html#h...
http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configu...
Other people have the same issue:
http://www.coderanch.com/t/564214/ORM/java/Hibernate-configuration-connec...
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.
Remove deprecation from Configuration until after new metamodel
completely in place
-----------------------------------------------------------------------------------
Key: HHH-6617
URL:
https://hibernate.onjira.com/browse/HHH-6617
Project: Hibernate ORM
Issue Type: Task
Reporter: Steve Ebersole
Assignee: Steve Ebersole
Decided to leave in place for {{Ejb3Configuration}} since JPA bootstrapping was always
the recommended and supported mechanism for JPA use cases.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira