-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate 3.1 - Error Parsing Session Factory XML
PostPosted: Sun Jan 22, 2006 3:40 pm 
Newbie

Joined: Sun Jan 22, 2006 3:25 pm
Posts: 6
Using MySQL 5 and Eclipse 3.1, which I believe to be irrelevant. The application worked fine with Hibernate 3.0.

Have changed hibernate.cfg.xml to include two new Hibernate 3.1 elements shown below:

<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

Note the doctype continues to refer to Hibernate 3.0 - is this appropriate?

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

Here is what I believe to be the relevant portion of the log, resulting from running the Ant task:

[java] 14:12:41,750 INFO Environment:479 - Hibernate 3.1.1
[java] 14:12:41,781 INFO Environment:509 - hibernate.properties not found
[java] 14:12:41,781 INFO Environment:525 - using CGLIB reflection optimizer
[java] 14:12:41,781 INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
[java] 14:12:41,921 INFO Configuration:1296 - configuring from resource: /hibernate.cfg.xml
[java] 14:12:41,921 INFO Configuration:1273 - Configuration resource: /hibernate.cfg.xml
[java] 14:12:42,156 ERROR XMLHelper:61 - Error parsing XML: /hibernate.cfg.xml(36) The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)".
[java] Initial SessionFactory creation failed.org.hibernate.MappingException: invalid configuration
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at events.HibernateUtil.<clinit>(Unknown Source)
[java] at events.EventManager.createAndStoreEvent(Unknown Source)
[java] at events.EventManager.main(Unknown Source)
[java] Caused by: org.hibernate.MappingException: invalid configuration
[java] at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1357)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:1298)
[java] at org.hibernate.cfg.Configuration.configure(Configuration.java:1284)
[java] ... 3 more
[java] Caused by: org.xml.sax.SAXParseException: The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)".
[java] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)

Thanks very much.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 22, 2006 3:45 pm 
Regular
Regular

Joined: Tue Oct 26, 2004 3:54 pm
Posts: 60
I guess you should post the entire hibernate.cfg.xml to clarify where the problem is.

Giulio


Top
 Profile  
 
 Post subject: Here is the Applicable hibernate.cfg.xml
PostPosted: Sun Jan 22, 2006 3:53 pm 
Newbie

Joined: Sun Jan 22, 2006 3:25 pm
Posts: 6
Thanks for the reply.

Here is the entire file contents:

<?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>

<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/sampdb</property>
<property name="connection.username">root</property>
<property name="connection.password">sammy11</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property><mapping resource="com/genuitec/hibernate/First.hbm.xml" />

<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>

<mapping resource="events/Event.hbm.xml"/>

</session-factory>

</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 22, 2006 4:00 pm 
Regular
Regular

Joined: Tue Oct 26, 2004 3:54 pm
Posts: 60
Code:
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property><mapping resource="com/genuitec/hibernate/First.hbm.xml" />


Move that <mapping> tag to the bottom, near the other one.

That should be it.

Giulio


Top
 Profile  
 
 Post subject: Thank You - I Wonder How that Happened?
PostPosted: Sun Jan 22, 2006 4:05 pm 
Newbie

Joined: Sun Jan 22, 2006 3:25 pm
Posts: 6
It works fine now. I have no idea how that damnable extra mapping became inserted.

Thanks very much for the help.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 22, 2006 4:07 pm 
Regular
Regular

Joined: Tue Oct 26, 2004 3:54 pm
Posts: 60
Cut and paste introduces funny errors in repetitive tasks (not to mention Find and Replace) ;)

Giulio


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