-->
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.  [ 3 posts ] 
Author Message
 Post subject: Elements in hibernate.cfg.xml
PostPosted: Wed Oct 08, 2003 6:12 pm 
Beginner
Beginner

Joined: Tue Oct 07, 2003 12:11 pm
Posts: 32
Location: US
I am new to Hibernate.

<hibernate-configuration>
<session-factory>
...
...
</session-factory>
</hibernate-configuration>

as per the http://hibernate.bluemars.net/hib_docs/reference/html/session-configuration.html doc

hibernate.connection.datasource is the only required element for <session-factory>

I have that in my hibernate.cfg

But when I run I get errors in the Borland App server. but my app works fine even after this error. The data is persisted in the DB. How can i fix this error?

org.xml.sax.SAXParseException: Element "session-factory" requires additional elements.
at org.apache.crimson.parser.Parser2.error(Parser2.java:3160)
at org.apache.crimson.parser.ValidatingParser$ChildrenValidator.done(ValidatingParser.java:361)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1519)
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:764)


Top
 Profile  
 
 Post subject: Please post more of your hibernate.cfg.xml. file
PostPosted: Wed Oct 08, 2003 6:44 pm 
Regular
Regular

Joined: Sun Sep 21, 2003 11:43 pm
Posts: 85
Location: Massachusetts
Do you have the DTD at the top of the hibernate.cfg.xml file?

Mine (2.0.2) uses (slightly obfuscatedto protect my innocence):

Quote:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>

<!-- properties -->
<!-- property name="connection.datasource">my/first/datasource</property> -->
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.username">hibernate</property>
<property name="connection.password">hibernate</property>
<property name="connection.url">jdbc:mysql://localhost:3306/hibernate?autoReconnect=true</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">false</property>
<property name="use_outer_join">true</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
<!--
<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
-->
<!-- mapping files -->
<mapping resource="eg/Login.hbm.xml"/>
<mapping resource="eg/Link.hbm.xml"/>
<mapping resource="eg/Product.hbm.xml"/>
</session-factory>

</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 10, 2003 9:40 am 
Beginner
Beginner

Joined: Tue Oct 07, 2003 12:11 pm
Posts: 32
Location: US
Thank you for your reply.

I was not having the tag <mapping resource="mapping.hbm.xml"/> in my cfg.xml.

I was setting the mapping in from my code, like -

configuration.addFile("C:/Hib/mapping.hbm.xml");

But the xml parser throws an exception if I am not having the <mapping resource="---"/> element

the exception
org.xml.sax.SAXParseException: Element "session-factory" requires additional elements.
at org.apache.crimson.parser.Parser2.error(Parser2.java:3160)
...
....

got fixed as I added the <mapping resource="---"/> tag.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.