我正在尝试将项目从Hibernate3 / Spring升级到当前版本。
我有Hibernate 5.0.7和Spring 4.2.4-Release。当我尝试执行我的代码时,我得到了:
java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:328)
org.springframework.orm.hibernate3.SessionFactoryUtils.getSession(SessionFactoryUtils.java:239)
org.springframework.orm.hibernate3.HibernateInterceptor.getSession(HibernateInterceptor.java:153)
org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:98)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
com.sun.proxy.$Proxy35.findFreightClassList(Unknown Source)
com.navajo.freight.web.controller.FreightRatesController.getFreightClassList(FreightRatesController.java:321)
我没有使用Maven,我非常仔细地检查了我的类路径。我确信类路径中没有旧版本的jar文件或类。
我的jar文件完整列表是:
activation-1.1.jar
antlr-2.7.7.jar
aopalliance.jar
axiom-api-1.2.8.jar
axiom-dom-1.2.8.jar
axiom-impl-1.2.8.jar
axis.jar
axis2-adb-1.5.1.jar
axis2-adb-codegen-1.5.1.jar
axis2-ant-plugin-1.5.1.jar
axis2-clustering-1.5.1.jar
axis2-codegen-1.5.1.jar
axis2-corba-1.5.1.jar
axis2-fastinfoset-1.5.1.jar
axis2-java2wsdl-1.5.1.jar
axis2-jaxbri-1.5.1.jar
axis2-jaxws-1.5.1.jar
axis2-jibx-1.5.1.jar
axis2-json-1.5.1.jar
axis2-kernel-1.5.1.jar
axis2-metadata-1.5.1.jar
axis2-mtompolicy-1.5.1.jar
axis2-saaj-1.5.1.jar
axis2-spring-1.5.1.jar
axis2-transport-http-1.5.1.jar
axis2-transport-local-1.5.1.jar
axis2-xmlbeans-1.5.1.jar
bcel-5.1.jar
commons-beanutils.jar
commons-codec-1.10.jar
commons-collections-3.1.jar
commons-discovery-0.2.jar
commons-fileupload-1.3.1.jar
commons-httpclient-3.1.jar
commons-io-2.4.jar
commons-lang-2.3.jar
commons-logging-1.1.3.jar
commons-validator-1.3.1.jar
dom4j-1.6.1.jar
estes_transittime.jar
files.lst
geronimo-jta_1.1_spec-1.1.1.jar
hibernate-commons-annotations-5.0.1.Final.jar
hibernate-core-5.0.7.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
httpcore-4.0.jar
jakarta-oro-2.0.8.jar
jalopy-1.5rc3.jar
jandex-2.0.0.Final.jar
javassist-3.18.1-GA.jar
javax-mail-1.5.4.jar
JAXB2_20061211.jar
jaxb-api-2.1.jar
jaxb-impl-2.1.7.jar
jaxb-xjc-2.1.7.jar
jaxen-1.1.1.jar
jaxrpc.jar
jboss-logging-3.3.0.Final.jar
jettison-1.0-RC2.jar
jibx-bind-1.2.1.jar
jibx-run-1.2.1.jar
jstl.jar
jta-1.1.jar
log4j-1.2.15.jar
mex-1.5.1.jar
neethi-2.0.4.jar
odfl.jar
saaj.jar
slf4j-api-1.5.2.jar
slf4j-log4j12-1.5.2.jar
smack-3.0.4.jar
smackx-3.0.4.jar
soapmonitor-1.5.1.jar
spring-aop-4.2.4.RELEASE.jar
spring-aspects-4.2.4.RELEASE.jar
spring-beans-4.2.4.RELEASE.jar
spring-context-4.2.4.RELEASE.jar
spring-context-support-4.2.4.RELEASE.jar
spring-core-4.2.4.RELEASE.jar
spring-expression-4.2.4.RELEASE.jar
spring-instrument-4.2.4.RELEASE.jar
spring-instrument-tomcat-4.2.4.RELEASE.jar
spring-jdbc-4.2.4.RELEASE.jar
spring-jms-4.2.4.RELEASE.jar
spring-messaging-4.2.4.RELEASE.jar
spring-orm-4.2.4.RELEASE.jar
spring-oxm-4.2.4.RELEASE.jar
spring-test-4.2.4.RELEASE.jar
spring-tx-4.2.4.RELEASE.jar
spring-web-4.2.4.RELEASE.jar
spring-webmvc-4.2.4.RELEASE.jar
spring-webmvc-portlet-4.2.4.RELEASE.jar
spring-websocket-4.2.4.RELEASE.jar
sqljdbc4.jar
standard.jar
ups_freight.jar
woden-api-1.0M8.jar
woden-impl-dom-1.0M8.jar
wsdl4j.jar
wstx-asl-3.2.4.jar
xalan-2.7.0.jar
xercesImpl-2.6.2.jar
xml-apis-1.3.02.jar
xmlbeans-2.3.0.jar
xml-resolver-1.2.jar
XmlSchema-1.4.3.jar
tomcat安装是库存,没有额外的罐子。
我一直在四处寻找,但我没有看到任何其他问题似乎是正确的。
答案 0 :(得分:2)
从日志中,你仍然使用hibernate 3 session factory
org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:328)
将会话工厂bean更改为使用hibernate 5
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- other configuration-->
</bean>