title: hibernate exception while running simple program
body: <p>I am trying to execute simple hibernate java program -</p>
  
  <p>files used : <strong>hibernate.cfg.xml, Employees.cfg.xml</strong><br>
  Java classes : <strong>HibernateUtil.java,Employees.java,Gender.java(Enum),InsertIntoEmployee.java</strong></p>
  
  <p>Code for <strong>InsertIntoEmployee.java</strong></p>
  
  <pre><code>package com.action.utilities.businessutilities;
  
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  
  import org.hibernate.HibernateException;
  import org.hibernate.Session;
  import org.hibernate.Transaction;
  
  import com.action.utilities.hibernateutilities.HibernateUtil;
  import com.hibernate.models.Employees;
  import com.hibernate.models.Gender;
  
  public class InsertIntoEmployee {
  
  public InsertIntoEmployee() {
  // TODO Auto-generated constructor stub
  }
  
  /**
  * @param args
  * @throws ClassNotFoundException 
  * @throws ParseException 
  */
  public static void main(String[] args) throws ClassNotFoundException {
  // TODO Auto-generated method stub
  SimpleDateFormat sdf=new SimpleDateFormat("MM/dd/yyyy");
  Class.forName("com.action.utilities.hibernateutilities.HibernateUtil");
  Session session=HibernateUtil.getSessionFactory().openSession();
  try {
  Transaction tx=session.beginTransaction();
  Employees emp=new Employees();
  emp.setFirstName("Gaurav");
  emp.setLastName("Palkar");
  emp.setBirthDate(sdf.parse("01/17/1983"));
  emp.setGender(Gender.MALE);
  session.save(emp);
  session.getTransaction().commit();
  } catch (HibernateException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
  }catch(ParseException pe){
  pe.printStackTrace();
  }catch(Exception ee){
  ee.printStackTrace();
  }finally{
  session.close();
  }
  }
  }
  </code></pre>
  
  <p>Getting the following error :</p>
  
  <pre><code>java.lang.NoClassDefFoundError: javax/transaction/SystemException
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:270)
  at org.jboss.logging.Logger.getMessageLogger(Logger.java:2248)
  at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214)
  at org.hibernate.cfg.Configuration.&lt;clinit&gt;(Configuration.java:176)
  at com.action.utilities.hibernateutilities.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:30)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:190)
  at com.action.utilities.businessutilities.InsertIntoEmployee.main(InsertIntoEmployee.java:29)
  Caused by: java.lang.ClassNotFoundException: javax.transaction.SystemException
  at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  ... 9 more
  Exception in thread "main" java.lang.NullPointerException
  at com.action.utilities.businessutilities.InsertIntoEmployee.main(InsertIntoEmployee.java:30)
  </code></pre>
  
  <p>Classpath Entries are all follows :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;classpath&gt;
  &lt;classpathentry kind="src" path="src"/&gt;
  &lt;classpathentry excluding="src/" kind="src" path=""/&gt;
  &lt;classpathentry kind="lib" path="lib/jta.jar"/&gt;
  &lt;classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/&gt;
  &lt;classpathentry kind="lib" path="lib/mysql-connector-java-5.1.18-bin.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/asm-attrs-1.5.3.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/c3p0-0.9.1.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/ehcache-1.2.3.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/ejb3-persistence-1.0.2.GA.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/jdbc-stdext-2.0.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/antlr-2.7.7.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/avro-1.5.1.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/hibernate-commons-annotations-4.0.1.Final.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/hibernate-core-4.1.3.Final.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/jackson-core-asl-1.9.2.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/jackson-mapper-asl-1.9.2.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/javassist-3.15.0-GA.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/jboss-logging-3.1.0.GA.jar"/&gt;    
  &lt;classpathentry kind="lib" path="lib/lucene-core-3.5.0.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/paranamer-2.3.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/slf4j-api-1.6.1.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/snappy-java-1.0.1-rc3.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/asm-3.1.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/cglib-2.1_3.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/commons-collections-3.1.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/&gt;
  &lt;classpathentry kind="lib" path="lib/log4j-1.2.13.jar"/&gt;
  &lt;classpathentry kind="output" path="bin"/&gt;
  &lt;/classpath&gt;
  </code></pre>
  
  <p>I am stuck with this issue for last three days.</p>
  
  <p>After googling I came to know if <strong>javaee-api-5.jar</strong> should be used to overcome issue but it did not help. I got classformaterror attached below -</p>
  
  <pre><code>java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract 
  in    class file javax/transaction/SystemException
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:270)
  at org.jboss.logging.Logger.getMessageLogger(Logger.java:2248)
  at org.jboss.logging.Logger.getMessageLogger(Logger.java:2214)
  at org.hibernate.cfg.Configuration.&lt;clinit&gt;(Configuration.java:176)
  at com.action.utilities.hibernateutilities.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:30)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:190)
  at com.action.utilities.businessutilities.InsertIntoEmployee.main(InsertIntoEmployee.java:29)
  Exception in thread "main" java.lang.NullPointerException
  at com.action.utilities.businessutilities.InsertIntoEmployee.main(InsertIntoEmployee.java:30)
  </code></pre>
  
  <p>I then also tried <strong>glassfish-api-4.0-b77.jar</strong> in the classpath then also it did not help.</p>
  
  <p>Can any body suggest to overcome the exception...</p>