-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problem configuring sessionFactory
PostPosted: Sat Jul 24, 2004 11:48 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Hi,

I am using Hibernate 2.1.2 with MySQL 4.1 on Resin 2.1.12. This is my first attempt at using Hibernate with MySQL and I have done pretty much the same things that I did with my previous implementation on SAPDB.

Code:
<property name="hibernate.connection.datasource">java:comp/env/hibernate/mysql/test</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.cache.provider_class">net.sf.hibernate.cache.HashtableCacheProvider</property>
<property name="hibernate.cglib.use_reflection_optimizer"> false</property>


It is using a Resin connection pool which works fine when using straight JDBC to get data from the DB.

Here is the code in my HibernateManager class.

Code:
static
{
  try
  {
    /**
     *  File name need not be specified here. By default hibernate.cfg.xml is
     *  chosen. However, if the file name is changed in the application, it
     *  will need to be modified here
     */

     logger.debug("loading session factory.");
     sessionFactory = new Configuration().configure().buildSessionFactory();
      logger.debug("Successfully created sessionFactory");
    }
    catch (HibernateException e)
    {
      logger.error("HibernateException building SessionFactory: " + Utilities.getStackTrace(e));
      throw new RuntimeException("HibernateException building SessionFactory: " + Utilities.getStackTrace(e), e);
    }
  }


The problem I have is that while the first logger gets written out, it never gets to the second logger and I don't get a HibernateException thrown.

I have the the following setup in my Log4J file but I am not getting any log entries which leads me to believe that Hibernate isn't getting initialized.

log4j.logger.net.sf.hibernate=DEBUG

Obviously, I am doing something really stupid and basic and even though I have been trying to figure it out the entire day I have had no success. Any help is greatly appreciated.

TIA


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 25, 2004 1:11 am 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Is there anything obvious that I am missing? I have tried everything recommended on the link below.

http://www.hibernate.org/hib_docs/refer ... ation.html


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 25, 2004 1:18 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Sorry for this bug in the HibernateUtil. Try this:
Code:
   // Create the initial SessionFactory from the default configuration files
   static {
      try {
         configuration = new Configuration();
         sessionFactory = configuration.configure().buildSessionFactory();
         // We could also let Hibernate bind it to JNDI:
         // configuration.configure().buildSessionFactory()
      } catch (Throwable ex) {
         // We have to catch Throwable, otherwise we will miss
         // NoClassDefFoundError and other subclasses of Error
         log.error("Building SessionFactory failed.", ex);
         throw new ExceptionInInitializerError(ex);
      }
   }


http://caveatemptor.hibernate.org/

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 25, 2004 1:40 am 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Thanks for the prompt response. I also noticed that I didn't have dom4j.jar in my classpath. Once I added that I started getting some logging. Let me try out your change request and get back to you.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 25, 2004 1:48 am 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
christian, thanks for your help. Using the Throwable told me precisely what my problem was, which was, yet again, a missing jar file. Specifically the cglib jar.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.