-->
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.  [ 8 posts ] 
Author Message
 Post subject: Cannot load properties in hibernate.cfg.xml
PostPosted: Wed Dec 03, 2003 12:53 am 
Regular
Regular

Joined: Tue Nov 04, 2003 12:37 pm
Posts: 57
Hello,

When calling the Configuration.configure(), it seems only loading the <mapping> files, but those <property> will not load.

The following is my hibernate.cfg.xml, the mapping file loads successfully and can create the table if I manually add those properties(database, driver, etc) in the program.

And I also see that some exception is out when running the programming.
The exception propbably tells "no dialect found, and use a generic dialect", "no db driver found", etc.

Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
    <!-- a SessionFactory instance listed as /jndi/name -->
    <session-factory name="hibernate/sessionFactory">
        <property name="show_sql">false</property>
        <property name="hibernate.show_sql">false</property>
       
        <property name="use_outer_join">true</property>
        <property name="hibernate.use_outer_join">true</property>
       
        <!--
        <property name="jta.UserTransaction">java:comp/UserTransaction/</property>
        <property name="hibernate.jta.UserTransaction">java:comp/UserTransaction/</property>
        -->
       
        <!-- properties for this SessionFactory only -->
        <!--
        <property name="connection.datasource">java:comp/env/jdbc/resume</property>
        -->
       
        <property name="dialect">net.sf.hibernate.dialect.HSQLDialect</property>
        <property name="hibernate.dialect">net.sf.hibernate.dialect.HSQLDialect</property>
       
        <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
                               
        <property name="connection.url">jdbc:hsqldb:data/test</property>
        <property name="hibernate.connection.url">jdbc:hsqldb:data/test</property>
       
       
       
        <property name="connection.username">SA</property>
        <property name="hibernate.connection.username">SA</property>
       
        <property name="connection.password"></property>
        <property name="hibernate.connection.password"></property>
       
        <!-- mapping files -->
        <mapping resource="model/Venue.hbm.xml"/>
        <mapping resource="model/Schedule.hbm.xml"/>
        <mapping resource="model/User.hbm.xml"/>
    </session-factory>
</hibernate-configuration>




Eric


Top
 Profile  
 
 Post subject: configure("/hibernate.cfg.xml") ?
PostPosted: Wed Dec 03, 2003 2:12 am 
Regular
Regular

Joined: Sun Sep 21, 2003 11:43 pm
Posts: 85
Location: Massachusetts
You are running configure with a filename, right?
(new Configuration()).configure("/hibernate.cfg.xml");

And not:

(new Configuration()).configure();

Regards,
David


Top
 Profile  
 
 Post subject: configure without givien file name.
PostPosted: Wed Dec 03, 2003 6:04 am 
Regular
Regular

Joined: Tue Nov 04, 2003 12:37 pm
Posts: 57
Hello,

I call as (new Configuration()).configure();


Eric


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 9:28 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Are you *sure* the proper hibernate.cfg.xml file is loaded ?
What happen if it is malformed ?
Do you have a hibernate.proeprties in your cp ?

Why did you double each property ?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 12:39 pm 
Newbie

Joined: Wed Nov 19, 2003 7:53 am
Posts: 6
Location: London
why do you need to pass hibernate.cfg.xml as a parameter to configure() ?

My understanding was that if the file name wasn't passed, the hibernate.cfg.xml file is searched for in the WEB-INF\classes root (TOMCAT)

Is this not correct.. ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 05, 2003 12:25 pm 
Senior
Senior

Joined: Sun Aug 31, 2003 3:14 pm
Posts: 151
Location: Earth (at the moment)
Quote:
My understanding was that if the file name wasn't passed, the hibernate.cfg.xml file is searched for in the WEB-INF\classes root (TOMCAT)


You are correct, I do this in my project and it works fine.

Are you sure it isn't something with Tomcat? I just started trying to deploy my app to difference servers the other day and it works fine in JRun 4 and JBoss 3.2.2 but not in Tomcat 5 and I don't know why yet (I'm not having trouble finding the hibernate.cfg.xml in Tomcat but it seems to be having trouble finding one or more of the .hbm.xml files mentioned in it).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 4:30 am 
Newbie

Joined: Thu Oct 28, 2004 10:20 pm
Posts: 3
hi,
I'm having a similar problem with JRun4. My 'hibernate.cfg.xml' is located in the WEB-INF/classes folder. But the xml file can't not be loaded. Can someone please help?

Terry


Code:
  Configuration cfg = new Configuration();
  cfg.configure();
  SessionFactory sessions = cfg.buildSessionFactory();
  Session session = sessions.openSession();
  ...



event.log (of the error):
11/05 03:13:29 info [axis] Hibernate 2.1.6
11/05 03:13:29 info [axis] hibernate.properties not found
11/05 03:13:29 info [axis] using CGLIB reflection optimizer
11/05 03:13:29 info [axis] configuring from resource: /hibernate.cfg.xml
11/05 03:13:29 info [axis] Configuration resource: /hibernate.cfg.xml
11/05 03:13:29 warning [axis] /hibernate.cfg.xml not found
11/05 03:13:29 info [axis] configuring from resource: /hibernate.cfg.xml
11/05 03:13:29 info [axis] Configuration resource: /hibernate.cfg.xml
11/05 03:13:29 warning [axis] /hibernate.cfg.xml not found
11/05 03:13:29 info [axis] configuring from resource: /hibernate.cfg.xml
11/05 03:13:29 info [axis] Configuration resource: /hibernate.cfg.xml
11/05 03:13:29 warning [axis] /hibernate.cfg.xml not found
11/05 03:14:13 user FlashGatewayServlet: destroy
11/05 03:14:13 user hib.Test: destroy
11/05 03:14:13 user ServletInvoker: destroy


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 06, 2004 6:42 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Put Hibernate2.jar in your web-inf/lib

_________________
Emmanuel


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