1 Reply Latest reply on Apr 4, 2012 4:27 AM by Haroon Foad

    From JBoss4 to JBoss AS7 HibernateUtil initialization

    Haroon Foad Newbie

      Dear all,

      I was running JSF1.2 , Richfaces3.3.3.Final, and hibernate3.2.6.ga on JBoss 4 successfully.

      But when migrating to JBoss AS7 , I face this error.


      java.lang.NoClassDefFoundError: Could not initialize class com.lit.wessald.mavenproject6.hibernateutil.HibernateUtil

      And this is my HibernateUtil.java

      package com.lit.wessald.mavenproject6.hibernateutil;
      import org.hibernate.SessionFactory;
      import org.hibernate.cfg.Configuration;
       * Hibernate Utility class with a convenient method to get Session Factory object.
       * @author hfoad
      public class HibernateUtil {
          private static final SessionFactory sessionFactory;
          static {
              try {
                  // Create the SessionFactory from standard (hibernate.cfg.xml) 
                  // config file.
                  sessionFactory = new Configuration().configure().buildSessionFactory();
              } catch (Throwable ex) {
                  // Log the exception. 
                  Log.getLogger(HibernateUtil.class.getName()).error("Initial SessionFactory creation failed." + ex);
                  throw new ExceptionInInitializerError(ex);
          public static SessionFactory getSessionFactory() {
              return sessionFactory;


      Any idea solving this issue?


        • 1. Re: From JBoss4 to JBoss AS7 HibernateUtil initialization
          Haroon Foad Newbie

          Thanks Allah,

          I have solved this issue by making changes in pom.xml as follow:

          1. change hibernate library from














          2.change the scope of the following dependency from provided to compile







          3.Add this dependency








          Thanks all.