java.lang.ClassNotFoundException:org.springframework.dao.DuplicateKeyException

时间:2014-11-19 08:50:09

标签: java hibernate spring-mvc

我正在尝试使用createQuery来获取数据。

Servlet.service() for servlet spring-mvc threw exception
java.lang.ClassNotFoundException: org.springframework.dao.DuplicateKeyException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.openSession(OpenSessionInViewFilter.java:171)
    at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:114)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)

3 个答案:

答案 0 :(得分:2)

下载org.springframework.transaction.jar并将其添加到您的类路径中。

答案 1 :(得分:0)

From here

复制

类DuplicateKeyException是spring-tx库的一部分。您需要将它添加到类路径中。你可以在这里得到它。

答案 2 :(得分:-1)

尝试插入或更新数据导致违反主键或唯一约束时抛出DuplicateKeyException异常。请注意,这不一定是纯粹的关系概念;大多数数据库类型都需要唯一的主键。