5 Replies Latest reply on May 16, 2011 9:52 AM by b.lambe

    unknown jboss error with hibernate

    b.lambe

      I have a class HibernateUtil.java

       

      public class HibernateUtil

      {

          private static final SessionFactory sessionFactory;

       

          static

          {

              sessionFactory = new Configuration().configure().buildSessionFactory();

          }

       

          public static SessionFactory getSessionFactory()

          {

              return sessionFactory;

          }

      }

       

      this reads in my hibernate.cfg.xml file

       

      i have deployed this on tomcat and glassfish seperately and it works fine, but as soon as i try and put it on jboss when i try and connect it throws the folloring error

       

      2011-05-16 14:04:28,149 ERROR [org.jboss.wsf.common.invocation.InvocationHandlerJAXWS] (http-127.0.0.1-8080-1) Method invocation failed with exception: null: java.lang.reflect.InvocationTargetException

       

      and

       

      Caused by: java.lang.NoClassDefFoundError: Could not initialize class HibernateUtil

       

      like i said this only happens with jboss, glassfish works fine, any ideas?

        • 1. unknown jboss error with hibernate
          alesj

          any ideas?

          You're getting some error / exception in your static init block, hence it cannot initialize the HibUtil class.

          Try catching that exception to see what is the real reason.

          • 2. unknown jboss error with hibernate
            b.lambe

            org.hibernate.AnnotationException

             

            java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)

             

             

            this is what i caught, but have no idea what to do with this? what does this tell me as to how to fix my issue?

             

            thanks in advance

            • 3. unknown jboss error with hibernate
              b.lambe

              hmmm

               

              i removed my hibernate jars and it seems to have go past this error message, but now i am getting

               

              java.sql.SQLException: No suitable driver found for jdbc:mysql://192.168.1.22/databasename

               

              i have the jar for mysql and my hibernate.cfg.xml looks like this

               

              <property name="connection.driver_class">com.mysql.jdbc.Driver</property>

              <property name="connection.url">jdbc:mysql://192.168.1.22/databasename</property>

              <property name="connection.username">username</property>

              <property name="connection.password">password</property>

              <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

               

              any ideas?

              • 4. unknown jboss error with hibernate
                alesj

                Put the MySQL jar into AS lib dir; e.g. <JBOSS_HOME>/common/lib/

                • 5. unknown jboss error with hibernate
                  b.lambe

                  figured it out

                   

                  You need to edit the file:

                   

                  server/${servername}/conf/jboss-service.xml and add

                   

                  <classpath codebase="${jboss.server.lib.url:lib}ext" archives="*"/>

                  rigth after

                   

                  <classpath codebase="${jboss.server.lib.url:lib}" archives="*"/>

                  then create a directory named:server/${servername}/lib/ext

                   

                  and drop your external jars in there.