-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem with 2 session factories
PostPosted: Thu Sep 25, 2003 10:58 am 
Newbie

Joined: Thu Sep 25, 2003 10:38 am
Posts: 3
Hi,
I need 2 session factories mapping 2 datasources and I got this error message :

ERROR [XMLHelper] Error parsing XML: /hibernate.cfg.xml(30)
org.xml.sax.SAXParseException: Element "hibernate-configuration" allows no further input; "session-factory" is not allowed.
at org.apache.crimson.parser.Parser2.error(Parser2.java:3160)
at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.consume(ValidatingParser.java:345)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1317)
at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:785)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)[/color]

This is my hibernate.cfg.xml file :
<?xml version='1.0'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<!-- shared properties -->


<!-- a SessionFactory instance listed as /secondfactory/sessionFactory -->
<session-factory name="/secondfactory/sessionFactory">

<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="dialect">cirrus.hibernate.sql.PostgreSQLDialect</property>
<property name="connection.driver">org.postgresql.Driver</property>
<property name="statement_cache.size">5</property>
<property name="show_sql">false</property>

<!-- properties for this SessionFactory only -->
<property name="connection.datasource">java:/SecondDB</property>

<!-- mapping files -->
<mapping resource="Company.hbm.xml"/>
<mapping resource="Customer.hbm.xml"/>

</session-factory>

<!-- a SessionFactory instance listed as /hibernate/sessionFactory -->
<session-factory name="/hibernate/sessionFactory">

<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="dialect">cirrus.hibernate.sql.PostgreSQLDialect</property>
<property name="connection.driver">org.postgresql.Driver</property>
<property name="statement_cache.size">5</property>
<property name="show_sql">false</property>

<!-- properties for this SessionFactory only -->
<property name="connection.datasource">java:/DefaultDS</property>

<!-- mapping files -->
<mapping resource="Mapping1.hbm.xml"/>
<mapping resource="Mapping2.hbm.xml"/>

</session-factory>

</hibernate-configuration>


What's wrong
Can someone help me ?
Tanks

_________________
Taylor


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 12:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
The dtd only allows one session-factory element per hibernate-configuration element. You need to break these two session-factory defs out into seperate config files.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 2:47 am 
Newbie

Joined: Thu Sep 25, 2003 10:38 am
Posts: 3
Thanks Steve.
How to specify which hibernate configuration file must be used ? hibernate.cfg.xml seems to be the hibernate configuration file by default so the second file is not considered.
I didn't find any example.

Thanks

_________________
Taylor


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2003 3:27 am 
Newbie

Joined: Thu Sep 25, 2003 10:38 am
Posts: 3
I found the solution :

SessionFactory sf = new Configuration().configure("/hibernate2.cfg.xml").buildSessionFactory();

_________________
Taylor


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

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.