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?

      Thanks.

        • 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

               <dependency>

                      <groupId>org.hibernate</groupId>

                      <artifactId>hibernate</artifactId>

                      <version>3.2.6.ga</version>

                      <scope>provided</scope>

                </dependency>

          to

               <dependency>

                      <groupId>org.hibernate</groupId>

                      <artifactId>hibernate-core</artifactId>

                      <version>3.6.10.Final</version>

               </dependency>

           

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

               <dependency>

                      <groupId>commons-collections</groupId>

                      <artifactId>commons-collections</artifactId>

                      <version>3.2</version>

               </dependency>

           

          3.Add this dependency

               <dependency>

                      <groupId>javassist</groupId>

                      <artifactId>javassist</artifactId>

                      <version>3.12.1.GA</version>

               </dependency>

           

           

          Thanks all.