-->
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.  [ 1 post ] 
Author Message
 Post subject: Basic Initialization issue
PostPosted: Mon Nov 16, 2009 1:30 pm 
Newbie

Joined: Mon Nov 16, 2009 1:24 pm
Posts: 1
Hi
I am new to hibernate.

I am using the HibernateUtil class as below:
Code:
public class HibernateUtil {

    private static final SessionFactory sessionFactory = buildSessionFactory();

    private static SessionFactory buildSessionFactory() {
      System.out.println("Did not enter the try block");
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            Configuration cfg = new Configuration();
            System.out.println("got a Cfg");
            cfg.configure("/WEB-INF/hibernate.cfg.xml");
            System.out.println("configured cfg");
            return cfg.buildSessionFactory();
            //return (new Configuration().configure("/WEB-INF/hibernate.cfg.xml")).buildSessionFactory();
        } catch (Error err) {
         err.printStackTrace();
         throw new ExceptionInInitializerError();
      } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.out.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        } finally {
         System.out.println("in finally");
         throw new ExceptionInInitializerError();
      }

    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

}


After running the code, in the log i see the syss out statement
"Did not enter the try block"
but i do not see the
"got a Cfg"

i.e. Control is stuck insie the new Configuration call.
No Exception thrown.
No Error thrown
Does not end up in the finally part.

Can anyone please help me know what is wrong with the code?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.