Announcement Announcement Module
Collapse
No announcement yet.
Could not initialize class org.hibernate.cfg.Configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Could not initialize class org.hibernate.cfg.Configuration

    Hi all,

    I am getting this exception after I try to load my app. I have the necessary hibernate jars in my classpath namely hibernate3.jar, hibernate-annotations.jar, hibernate-entitymanager.jar and hibernate-commons-annotations.jar. I have configured hibernate through spring. Here is my spring config:

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
    <property name="url" value="jdbc:mysql://localhost:3306/db"></property>
    <property name="username" value="abc"></property>
    <property name="password" value="abc123"></property>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotati on.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="annotatedClasses">
    <list>
    <value>com.gex.domain.NewAccount</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQ LDialect</prop>
    </props>
    </property>
    </bean>

    I also tried using a hibernate.properties file with the database settings but that did not help either.

    The exception trace is:

    Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/gex-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.Anno tationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.Configuration

    Any help with this issue will be greatly appreciated. Thanks in advance.

  • #2
    I think you missed some Spring libraries.

    Check out your Spring libraries are on path basically it is showing the error for class which is not in hibernate but Spring.

    Comment


    • #3
      I do have the spring libs in the classpath, namely spring.jar, spring-mvc.jar, spring-context.jar, spring-jdbc.jar, spring-core.jar, etc.

      Comment


      • #4
        Look in:

        http://forum.springframework.org/showthread.php?t=64837

        org.hibernate.cfg.Configuration is from hibernate-core.jar

        Comment


        • #5
          There is no jar called hibernate-core.jar. You must be referring to the zip file which in turn contains hibernate3.jar which contains org.hibernate.cfg.Configuration.class. As I mentioned in my post, I already have hibernate3.jar in my classpath and I also made sure that it contains the Configuration class.

          Comment


          • #6
            Ok, hibernate3.jar,

            Is your application web application? Can you check is hibernate3.jar jar deployed to application server?

            Comment


            • #7
              Yes, it has deployed it to the app server, in my case JBoss.

              Comment


              • #8
                What exact version of hibernate do you use?

                Comment


                • #9
                  The version shipped along with Spring 2.5.5, it's Hibernate 3 but I'm not sure of the exact version.

                  Comment


                  • #10
                    Can you check following libraries in classpath?

                    Code:
                    dom4j-1.6.1.jar
                    log4j-1.2.15.jar
                    slf4j-api-1.5.0.jar
                    slf4j-log4j12-1.5.0.jar
                    Last edited by Andrei Tsibets; Dec 24th, 2008, 04:32 PM.

                    Comment


                    • #11
                      Version is: 3.3.0.CR1

                      Comment


                      • #12
                        I will check those when i get home. Thanks for the help.

                        Comment


                        • #13
                          Hey Andrei, I added those jars that you mentioned and that got rid of the exception. Thanks again.

                          Comment

                          Working...
                          X