-->
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: java.lang.ExceptionInInitializerError with Hibernate IDE
PostPosted: Fri Dec 07, 2007 5:08 pm 
Newbie

Joined: Fri Dec 07, 2007 3:30 am
Posts: 1
Hi,

I am newbie to Hibernate. I wanted to run a simple hibernate example from the Java Persistence with Hibernate. This helloworld-native works fine with ant build tool. when i try to use the Hibernate IDE, i get the below stack trace.

I have googled and tried searching for the mistake i have done. The hibernate IDE doesnt have a runnable example for Eclipse.

The stack trace is,

Code:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.ExceptionInInitializerError
   at persistence.HibernateUtil.<clinit>(HibernateUtil.java:21)
   at hello.HelloWorld.main(HelloWorld.java:16)
Caused by: java.lang.ExceptionInInitializerError
   at org.hibernate.cfg.Configuration.reset(Configuration.java:168)
   at org.hibernate.cfg.Configuration.<init>(Configuration.java:187)
   at org.hibernate.cfg.Configuration.<init>(Configuration.java:191)
   at persistence.HibernateUtil.<clinit>(HibernateUtil.java:18)
   ... 1 more
Caused by: java.lang.NullPointerException
   at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:144)
   at org.hibernate.cfg.Environment.<clinit>(Environment.java:529)
   ... 5 more


The hibernate cfg file is same as the one provided in the Message Example.,

Code:
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration
        PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.max_size">20</property>
        <property name="hibernate.c3p0.timeout">300</property>
        <property name="hibernate.c3p0.max_statements">50</property>
        <property name="hibernate.c3p0.idle_test_period">3000</property>
       

        <!-- SQL to stdout logging
        <property name="show_sql">true</property>
        <property name="format_sql">true</property>
        <property name="use_sql_comments">true</property>
        -->

        <property name="dialect">org.hibernate.dialect.HSQLDialect</property>
        <mapping resource="hello/Message.hbm.xml"/>
    </session-factory>
</hibernate-configuration>


The Hibernate Util .java is


Code:
package persistence;

import java.io.File;

import org.hibernate.*;
import org.hibernate.cfg.*;

/**
* Startup Hibernate and provide access to the singleton SessionFactory
*/
public class HibernateUtil {

  private static SessionFactory sessionFactory;
  private static Configuration config;

  static {
    try {
       config = new Configuration().configure();
       sessionFactory = config.buildSessionFactory();
    } catch (Throwable ex) {
       throw new ExceptionInInitializerError(ex);
    }
  }

  public static SessionFactory getSessionFactory() {
      // Alternatively, we could look up in JNDI here
      return sessionFactory;
  }

  public static void shutdown() {
      // Close caches and connection pools
      getSessionFactory().close();
  } 
}


I can feel that this should be my mistake somewhere. But i wonder that i couldnt find any post talking about this particular minor problem.

Regards,


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.