java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session

后端 未结 4 2048
旧时难觅i
旧时难觅i 2020-11-29 07:24

i am trying to integrate my already working spring project with hibernate, but this is the error i am getting on start up.

EVERE: Servlet.service() for servl         


        
4条回答
  •  误落风尘
    2020-11-29 08:14

    The problem is that you have hibernate-core-4.0.0.Final.jar in your classpath, but Spring 3.1 uses hibernate-core-3.6.0.Final.jar (see here Spring 3.1 artifact and dependencies).

    Remove Hibernate 4.0 and put Hibernate 3.6 instead in your classpath.

    BTW, there might some more such miss matches. It's better to use maven to take care of dependencies.

    EDIT - some more details

    In Hibernate 3.6 the interface Session was in package org.hibernate.classic whereas in Hibernate 4.0 it was moved to the package org.hibernate.

    In Hibernate 3.6 the SessionFactory.openSession no longer returns an org.hibernate.classic.Session, rather it returns an org.hibernate.Session. This is a refactor that breaks client code...

提交回复
热议问题