tjholmes66
tjholmes66

Reputation: 1998

Spring 4 and Hibernate 5 gives NoSuchMethodError org.hibernate.internal.CoreMessageLogger

So, I had a successful Spring 4.2.2.RELEASE MVC web-app working with Hibernate 4.3.8.Final. I changed to Hibernate 5.0.2.Final, and I made the following changes to my spring application context file.

From:

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

To:

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">

And from:

<bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">

To:

<bean id="transactionManager"
    class="org.springframework.orm.hibernate5.HibernateTransactionManager">

I can't find this issue anywhere else on the net. I know for sure that I checked my classpath and there is no other Hibernate4 reference anywhere in this application on any level.

When I try to execute my DaoTestCode, the Spring application context will not load because of this error message:

java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debug

I have tried to find other places on the net where it shows the proper configuration for Hibernate 5 with Spring 4.2.2, and I can't find anything. I know I went through some pain going from Hibernate 3 to Hibernate 4, and now I want to migrate up accordingly. I knew there would be some pain points. Is there any way to solve this issue, and any other future issues I should be aware of?

Thanks!

Upvotes: 0

Views: 3323

Answers (2)

androidominus
androidominus

Reputation: 59

I think it's a classpath problem.

Have you checked in the libs of your application server?

The method org.hibernate.internal.CoreMessageLogger.debug is inherited from org.jboss.logging.BasicLogger and was added since hibernate 4. Do you have jboss-logging in your classpath with right version?

Maybe you have hibernate 3 lib in your classpath?

Upvotes: 0

tjholmes66
tjholmes66

Reputation: 1998

Updated my pom file to update all my logging jars to the latest:

    <!-- Logging Dependencies -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun.jdmk</groupId>
                <artifactId>jmxtools</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jmx</groupId>
                <artifactId>jmxri</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.jms</groupId>
                <artifactId>jms</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.12</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.3.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.12</version>
    </dependency>

And this solved my problem!

Upvotes: 3

Related Questions