Although we have been able to use the deprecated approach to building the session factory - our attempts to do so use the newer ServiceRegistryBuilder approach fail with what appear to be XML parsing failures.
The code we are using:
Quote:
SQL_LOGGER.debug( "About to create session factory" );
URL url = this.getClass().getResource( "/hibernate.cfg.xml" );
ServiceRegistryBuilder srb = new ServiceRegistryBuilder().configure(url.toExternalForm() );
ServiceRegistry basicServiceRegistry = srb.buildServiceRegistry();
MetadataSources sources = new MetadataSources( basicServiceRegistry );
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
mSessionFactory = metadata.getSessionFactoryBuilder().buildSessionFactory();
The exception always comes back as:
Code:
org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line
number 5 and column 26 in RESOURCE file:/C:/p4root/branches/jlb/classes/hibernate.cfg.xml.
Message: cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.
at org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:120) ~[hibernate-core.jar:4.0.0.Final]
at org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:69) ~[hibernate-core.jar:4.0.0.Final]
at org.hibernate.service.ServiceRegistryBuilder.configure(ServiceRegistryBuilder.java:162) ~[hibernate-core.jar:4.0.0.Final]
at com.altosresearch.utils.DBUtils.createSession(DBUtils.java:79) ~[classes/:na]
The hibernate.cfg.xml file looks like this:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="foo">
<property name="connection.username">asdfasdf</property>
<property name="connection.password">asfdasdf</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="connection.url">jdbc:postgresql://127.0.0.1:5432/altos_research</property>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>
<property name="query.substitutions">yes 'Y', no 'N'</property>
....
I have verified that the URL to the DTD -
http://hibernate.sourceforge.net/hibern ... on-3.0.dtd - still resolve correctly. Any ideas? For now, we'll continue to use the old style method:
Code:
SQL_LOGGER.debug( "About to create session factory" );
URL url = this.getClass().getResource( "/hibernate.cfg.xml" );
Configuration cf = new Configuration().configure(url);
mSessionFactory = cf.buildSessionFactory();