-->
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.  [ 7 posts ] 
Author Message
 Post subject: problem parsing configuration/hibernate.cfg.xml
PostPosted: Tue Jun 07, 2005 10:27 am 
Beginner
Beginner

Joined: Tue May 17, 2005 7:39 am
Posts: 27
Location: Rome, Italy
Hibernate version:
3.0

Code between sessionFactory.openSession() and session.close():
i am trying to run a simple tomcat example from hibernate reference, i post the main() i run and that gives the exception:

Code:
public static void main(String[] args) {
       
        Session session = HibernateUtil.currentSession();
       
       
        Transaction tx= session.beginTransaction();
       
       
         
        Cat princess = new Cat();
        princess.setName("Princess");
        princess.setSex('F');
        princess.setWeight(7.4f);
       
       
        session.save(princess);
       
       
        tx.commit();
       
       
       
       
        HibernateUtil.closeSession();

    }



Full stack trace of any exception that occurs:
Caused by: org.hibernate.HibernateException: problem parsing configuration/hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1223)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1162)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1148)
at HibernateUtil.<clinit>(HibernateUtil.java:29)
Caused by: org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1218)
... 3 more
Exception in thread "main"

Name and version of the database you are using:

mysql 41

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 3:02 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Please post your Hibernate configuration (hibernate.cfg.xml).
I guess there's something wrong with your DTD.

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


Best regards
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 08, 2005 4:58 am 
Beginner
Beginner

Joined: Tue May 17, 2005 7:39 am
Posts: 27
Location: Rome, Italy
here's my hibernate.cfg.xml, i guess the version of the dtd is not the problem. thanx for the reply, now i will search the forum for other issues.

Code:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
   PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>
      <property name="connection.datasource">jdbc:mysql://localhost:3306/quickstart</property>
      <property name="show_sql">false</property>
      <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
                <property name="connection.username">root</property> 
                <property name="connection.password">******</property>
   <!-- Mapping files -->
   <mapping resource="net/sf/hibernate/examples/quickstart/Cat.hbm.xml"/>
   </session-factory>
</hibernate-configuration>




Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 08, 2005 5:28 am 
Beginner
Beginner

Joined: Tue May 17, 2005 7:39 am
Posts: 27
Location: Rome, Italy
sorry, the problem i had with parsing the xml was the one you said, and i solved it replacing the dtd version 2.0 with 3.0 like you suggested.
now i have another problem with datasource, so i will search the forum for other issues... i suck at understanding hibernate cfg...

Code:


log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
java.lang.ExceptionInInitializerError
    at HibernateUtil.<clinit>(HibernateUtil.java:32)
Caused by: org.hibernate.HibernateException: Could not find datasource
    at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:48)
    at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
    at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:349)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:58)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1509)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
    at HibernateUtil.<clinit>(HibernateUtil.java:29)
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
    at javax.naming.InitialContext.lookup(InitialContext.java:351)
    at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
    ... 6 more
Exception in thread "main"
Java Result: 1











Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 9:30 pm 
Newbie

Joined: Mon Jul 31, 2006 1:47 am
Posts: 6
Even I had a same problem but even when i change the dtd version 3.0 to dtd version 2.0 it worked for me!! any idea Y it is??


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 3:01 am 
Beginner
Beginner

Joined: Thu Jun 09, 2005 3:18 am
Posts: 34
Location: India
I think you have to specify the following in hibernate config file
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>

you have to put the driver file in class path


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 9:04 pm 
Newbie

Joined: Thu Sep 14, 2006 8:49 pm
Posts: 2
Anyone tried browsing to hibernate.sourceforge.net? It is has been down (for me anyways) off and on for the past few days so it can't find the DTD. I have had to manually edit the xml files to point to the dtd in the hibernate3.jar!


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