title: java.lang.NullPointerException in a sample program of Hibernate
body: <p>i am try to run a sample application of hibernate, it give me a error on run time:</p>
  
  <blockquote>
    <p>log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).<br>
    log4j:WARN Please initialize the log4j system properly.<br>
    Exception in thread "main" java.lang.NullPointerException
        at transaction.rollback();</p>
  </blockquote>
  
  <p>this is in Main.java:</p>
  
  <pre><code>public class Main {
  
  public static void main(String[] args) {
      Session session = HibernateUtil.getSessionFactory().openSession();
      Transaction transaction = null;
      try {
          transaction = session.beginTransaction();
          Address address = new Address("ABC", "Delhi", "TN", "110001");
          Student student = new Student("kumar", address);
          session.save(student);
          transaction.commit();
      } catch (HibernateException e) {
          transaction.rollback();
          e.printStackTrace();
      } finally {
          session.close();
      }
  </code></pre>