These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: v4.0.0 - Unable to create session factory with SRB
PostPosted: Fri Dec 16, 2011 8:59 pm 
Newbie

Joined: Thu May 08, 2008 3:11 pm
Posts: 6
Location: Mountain View, CA
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();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.