File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes hibernate.cfg.xml problem on startup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate.cfg.xml problem on startup" Watch "hibernate.cfg.xml problem on startup" New topic

hibernate.cfg.xml problem on startup

jim mcnamara
Ranch Hand

Joined: Jun 13, 2007
Posts: 70

i've noticed that hibernate is pulling settings out of memory somehow.
i tried to set my hibernate.cfg.xml and put the db path in

but the probelm is that even after i go in and change the file
/usr/lib/JADE/hibernate.cfg.xml, iit might pick up a prior setting .

it definitely has a mind of its own on start up and i'd really like to
know why on startup it isnt reading my hibernate.cfg.xml

what i am trying to do is let the user edit the hibernate.cfg.xml
in /usr/lib/JADE and change the db path to anywhere on their system.

thanks for any assistance - 3rdshiftcoder

here is my hibernate.util:

package db2;

import org.hibernate.*;

import org.hibernate.cfg.*;

import org.dom4j.*;


public class HibernateUtil {

private static SessionFactory sessionFactory;

static {

try {

AnnotationConfiguration cfg = (AnnotationConfiguration) new AnnotationConfiguration();







cfg.configure(new File("/usr/lib/JADE/hibernate.cfg.xml"));


} catch (Throwable ex) {

throw new ExceptionInInitializerError(ex);



public static SessionFactory getSessionFactory() {

// Alternatively, you could look up in JNDI here

return sessionFactory;


public static void shutdown() {

// Close caches and connection pools



my hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
<property name="hibernate.connection.password">user1</property>
<property name="hibernate.connection.url">jdbc:derby:/home/thirdshift/JADE_DB</property>
<property name="hibernate.connection.username">user1</property>
<property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
<mapping class="db2.GlLineItem" />
<mapping class="db2.GLMaster" />
<mapping class="db2.Category" />
<mapping class="db2.Invoice" />
<mapping class="db2.InvoiceDetail" />

jim mcnamara
Ranch Hand

Joined: Jun 13, 2007
Posts: 70

i dont know man. it (my program) seems to be working.
i have it set up so the db is in /usr/lib/JADE

i figure if i put the db there and leave the db name always
JADE_DB then i am safe.

i had initially thought i'd like for the user to be able to move
the db around on the pc but hibernate is out of its mind today.

either that will or wont be acceptable to the user.

i am putting it up on my site now. it should be up in another
1/2 hour.

i guess never mind the question. if anyone would check it out,
that would be cool. that way i have feedback on my deployment
on another machine. if not, i understand.

I agree. Here's the link:
subject: hibernate.cfg.xml problem on startup
jQuery in Action, 3rd edition