更新到休眠4并更改一些所需设置后,我收到以下错误:
SEVERE: Servlet.service() for servlet [default] in context with path [/ESBCollector] threw exception [Filter execution threw an exception] with root cause
java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
at org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:328)
at org.springframework.orm.hibernate3.SessionFactoryUtils.getSession(SessionFactoryUtils.java:208)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.getSession(OpenSessionInViewFilter.java:294)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:208)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
看起来hibernate3仍然用于打开会话。我忘记做的任何想法?
答案 0 :(得分:2)
必须在web.xml中更改openSessionInViewFilter
答案 1 :(得分:1)
您需要运行mvn dependency:tree
并在输出中搜索Hibernate 3 jar。当您发现依赖项将Hibernate 3添加到依赖关系树时,您需要简单地排除它们,如下所示:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
</exclusions>
</dependency>
答案 2 :(得分:1)
您正在使用hibernate4但是web.xml
仍然使用hibernate3的[OpenSessionInViewFilter
]代替hibernate4的[OpenSessionInViewFilter
]。
要修复web.xml
。
<filter>
<filter-name>osiv-filter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
用4替换3。
<filter>
<filter-name>osiv-filter</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
</filter>
答案 3 :(得分:1)
您可能在代码中导入了旧的(hibernate3)类,例如
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
// needs to be replaced to
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;