title: Hibernate's Session exception
body: <p>Im new in hebirnate.  Try execute example code.</p>
  
  <pre><code>public class HibernateUtil {
  
  private static final SessionFactory sessionFactory;
  
  static {
      try {
          // Create the SessionFactory
          sessionFactory = new Configuration().configure().buildSessionFactory();
      } catch (HibernateException ex) {
          throw new RuntimeException("Configuration problem: " + ex.getMessage(), ex);
      }
  }
  
  public static final ThreadLocal session = new ThreadLocal();
  
  public static Session currentSession() throws HibernateException {
      Session s = (Session) session.get();
      // Open a new Session, if this Thread has none yet
      if (s == null) {
          s = sessionFactory.openSession();
          session.set(s);
      }
      return s;
  }
  
  public static void closeSession() throws HibernateException {
      Session s = (Session) session.get();
      session.set(null);
      if (s != null)
          s.close();
  }
  }
  
  
  public class javism_jaxb_xml_to_object {
  public static void main(String[] args) throws JAXBException
  {
      Session session = HibernateUtil.currentSession();
    Transaction tx = null;
      tx = session.beginTransaction();
              javism_jaxb cust = new javism_jaxb();
              cust.setName("Vasay");
              cust.setId(1);
              cust.setAge(34);
              session.save(cust);
              tx.commit();
  }
  }
  </code></pre>
  
  <p>But get exeption</p>
  
  <pre><code>  Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
  at org.hibernate.cfg.Configuration.&lt;clinit&gt;(Configuration.java:111)
  at test.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:16)
  at test.javism_jaxb_xml_to_object.main(javism_jaxb_xml_to_object.java:25)
  Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
  at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
  ... 3 more
  </code></pre>
  
  <p>What im doing wrong?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>After adding commons-logging-1.1.1.jar in classpath. And refreshing hibernate3.jar from 3.0.3 to 3.5 i get another exeption</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
  at test.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:16)
  at test.javism_jaxb_xml_to_object.main(javism_jaxb_xml_to_object.java:25)
  Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
  at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
  ... 2 more
  </code></pre>
  
  <p>but if i use hibernate3.jar version 3.0.3 i get this</p>
  
  <pre><code>15.08.2012 11:01:30 org.hibernate.cfg.Environment &lt;clinit&gt;
  INFO: Hibernate 3.0.3
  15.08.2012 11:01:30 org.hibernate.cfg.Environment &lt;clinit&gt;
  INFO: hibernate.properties not found
  15.08.2012 11:01:30 org.hibernate.cfg.Environment &lt;clinit&gt;
  INFO: using CGLIB reflection optimizer
  15.08.2012 11:01:30 org.hibernate.cfg.Environment &lt;clinit&gt;
  INFO: using JDK 1.4 java.sql.Timestamp handling
  15.08.2012 11:01:30 org.hibernate.cfg.Configuration configure
  INFO: configuring from resource: /hibernate.cfg.xml
  15.08.2012 11:01:30 org.hibernate.cfg.Configuration getConfigurationInputStream
  INFO: Configuration resource: /hibernate.cfg.xml
  </code></pre>