Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

hibernate.cfg.xml problem on startup  RSS feed

jim mcnamara
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!