hibernate – 调用init方法失败;嵌套异常是java.lang.IncompatibleClassChangeError:实现类

前端之家收集整理的这篇文章主要介绍了hibernate – 调用init方法失败;嵌套异常是java.lang.IncompatibleClassChangeError:实现类前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

错误信息:

  1. SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  2. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [config/spring/Hibernate-ctx.xml]: Invocation of init method Failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
  3. at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.initializeBean(AbstractAutowireCapablebeanfactory.java:1338)
  4. at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:473)
  5. at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory$1.run(AbstractAutowireCapablebeanfactory.java:409)
  6. at java.security.AccessController.doPrivileged(Native Method)
  7. at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBean(AbstractAutowireCapablebeanfactory.java:380)
  8. at org.springframework.beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:264)
  9. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  10. at org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:261)
  11. at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:185)
  12. at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:164)
  13. at org.springframework.beans.factory.support.DefaultListablebeanfactory.preInstantiateSingletons(DefaultListablebeanfactory.java:423)
  14. at org.springframework.context.support.AbstractApplicationContext.finishbeanfactoryInitialization(AbstractApplicationContext.java:728)
  15. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
  16. at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
  17. at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
  18. at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
  19. at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
  20. at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
  21. at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
  22. at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
  23. at java.util.concurrent.FutureTask.run(FutureTask.java:166)
  24. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
  25. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
  26. at java.lang.Thread.run(Thread.java:722)
  27. Caused by: java.lang.IncompatibleClassChangeError: Implementing class
  28. at java.lang.ClassLoader.defineClass1(Native Method)
  29. at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
  30. at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  31. at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)
  32. at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)
  33. at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
  34. at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
  35. at java.lang.Class.getDeclaredConstructors0(Native Method)
  36. at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
  37. at java.lang.Class.getConstructor0(Class.java:2714)
  38. at java.lang.Class.getDeclaredConstructor(Class.java:2002)
  39. at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:78)
  40. at org.springframework.orm.hibernate3.LocalSessionfactorybean.newConfiguration(LocalSessionfactorybean.java:772)
  41. at org.springframework.orm.hibernate3.LocalSessionfactorybean.buildSessionFactory(LocalSessionfactorybean.java:517)
  42. at org.springframework.orm.hibernate3.AbstractSessionfactorybean.afterPropertiesSet(AbstractSessionfactorybean.java:211)
  43. at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.invokeInitMethods(AbstractAutowireCapablebeanfactory.java:1369)
  44. at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.initializeBean(AbstractAutowireCapablebeanfactory.java:1335)
  45. ... 23 more

使用tomcat 7和maven构建.

mvn依赖:tree -Dverbose给出以下消息:

  1. C:\project>mvn dependency:tree -Dverbose
  2. [INFO] Scanning for projects...
  3. [INFO] Searching repository for plugin with prefix: 'dependency'.
  4. [INFO] ------------------------------------------------------------------------
  5. [INFO] Building home-app
  6. [INFO] task-segment: [dependency:tree]
  7. [INFO] ------------------------------------------------------------------------
  8. [INFO] [dependency:tree {execution: default-cli}]
  9. [INFO] com.home.app:home-app:war:0.0.1
  10. [INFO] +- org.springframework:spring-orm:jar:3.0.5.RELEASE:compile
  11. [INFO] | +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
  12. [INFO] | | \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  13. [INFO] | +- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  14. [INFO] | +- org.springframework:spring-jdbc:jar:3.0.5.RELEASE:compile
  15. [INFO] | | +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  16. [INFO] | | +- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  17. [INFO] | | \- (org.springframework:spring-tx:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  18. [INFO] | \- (org.springframework:spring-tx:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  19. [INFO] +- log4j:log4j:jar:1.2.14:runtime (scope not updated to compile)
  20. [INFO] +- MysqL:MysqL-connector-java:jar:5.1.17:compile
  21. [INFO] +- org.hibernate:ejb3-persistence:pom:3.3.2.Beta1:compile
  22. [INFO] +- org.hibernate:hibernate-core:jar:3.6.7.Final:compile
  23. [INFO] | +- antlr:antlr:jar:2.7.6:compile
  24. [INFO] | +- commons-collections:commons-collections:jar:3.1:compile
  25. [INFO] | +- dom4j:dom4j:jar:1.6.1:compile
  26. [INFO] | +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
  27. [INFO] | | \- (org.slf4j:slf4j-api:jar:1.5.8:compile - omitted for conflict with 1.6.1)
  28. [INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
  29. [INFO] | +- javax.transaction:jta:jar:1.1:compile
  30. [INFO] | \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for conflict with 1.5.8)
  31. [INFO] +- commons-dbcp:commons-dbcp:jar:1.2.2:compile
  32. [INFO] | \- commons-pool:commons-pool:jar:1.3:compile
  33. [INFO] +- org.springframework:spring-hibernate3:jar:2.0.8:compile
  34. [INFO] | +- aopalliance:aopalliance:jar:1.0:compile
  35. [INFO] | +- commons-logging:commons-logging:jar:1.1:compile
  36. [INFO] | | +- (log4j:log4j:jar:1.2.12:compile - omitted for conflict with 1.2.14)
  37. [INFO] | | +- logkit:logkit:jar:1.0.1:compile
  38. [INFO] | | +- avalon-framework:avalon-framework:jar:4.1.3:compile
  39. [INFO] | | \- (javax.servlet:servlet-api:jar:2.3:compile - omitted for conflict with 3.0-alpha-1)
  40. [INFO] | +- org.hibernate:hibernate:jar:3.2.5.ga:compile
  41. [INFO] | | +- net.sf.ehcache:ehcache:jar:1.2.3:compile
  42. [INFO] | | | +- (commons-logging:commons-logging:jar:1.0.4:compile - omitted for conflict with 1.
  43. [INFO] | | | \- (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict w
  44. [INFO] | | +- (javax.transaction:jta:jar:1.0.1B:compile - omitted for conflict with 1.1)
  45. [INFO] | | +- (commons-logging:commons-logging:jar:1.0.4:compile - omitted for conflict with 1.1)
  46. [INFO] | | +- asm:asm-attrs:jar:1.5.3:compile
  47. [INFO] | | +- (dom4j:dom4j:jar:1.6.1:compile - omitted for duplicate)
  48. [INFO] | | +- (antlr:antlr:jar:2.7.6:compile - omitted for duplicate)
  49. [INFO] | | +- (cglib:cglib:jar:2.1_3:compile - omitted for conflict with 2.2.2)
  50. [INFO] | | +- (asm:asm:jar:1.5.3:compile - omitted for conflict with 3.3.1)
  51. [INFO] | | \- (commons-collections:commons-collections:jar:2.1.1:compile - omitted for conflict wi
  52. [INFO] | +- (org.springframework:spring-beans:jar:2.0.8:compile - omitted for conflict with 3.0.5.R
  53. [INFO] | +- (org.springframework:spring-context:jar:2.0.8:compile - omitted for conflict with 3.0.5
  54. [INFO] | +- (org.springframework:spring-core:jar:2.0.8:compile - omitted for conflict with 3.0.5.RE
  55. [INFO] | +- org.springframework:spring-dao:jar:2.0.8:compile
  56. [INFO] | | +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
  57. [INFO] | | +- (commons-logging:commons-logging:jar:1.1:compile - omitted for duplicate)
  58. [INFO] | | +- (org.springframework:spring-beans:jar:2.0.8:compile - omitted for conflict with 3.0.
  59. [INFO] | | +- (org.springframework:spring-context:jar:2.0.8:compile - omitted for duplicate)
  60. [INFO] | | \- (org.springframework:spring-core:jar:2.0.8:compile - omitted for conflict with 3.0.5
  61. [INFO] | \- (org.springframework:spring-jdbc:jar:2.0.8:compile - omitted for conflict with 3.0.5.RE
  62. [INFO] +- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
  63. [INFO] | \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  64. [INFO] +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
  65. [INFO] | +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
  66. [INFO] | +- (org.springframework:spring-asm:jar:3.0.5.RELEASE:compile - omitted for conflict with 3
  67. [INFO] | +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  68. [INFO] | \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  69. [INFO] +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
  70. [INFO] | +- (org.springframework:spring-aop:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  71. [INFO] | +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  72. [INFO] | +- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  73. [INFO] | +- (org.springframework:spring-expression:jar:3.0.5.RELEASE:compile - omitted for duplicat
  74. [INFO] | \- (org.springframework:spring-asm:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  75. [INFO] +- org.springframework:spring-tx:jar:3.0.5.RELEASE:compile
  76. [INFO] | +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
  77. [INFO] | +- (org.springframework:spring-aop:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  78. [INFO] | +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  79. [INFO] | +- (org.springframework:spring-context:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  80. [INFO] | \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  81. [INFO] +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
  82. [INFO] | +- (org.springframework:spring-asm:jar:3.0.5.RELEASE:compile - omitted for duplicate)
  83. [INFO] | \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.1)
  84. [INFO] +- cglib:cglib:jar:2.2.2:compile
  85. [INFO] | \- asm:asm:jar:3.3.1:compile
  86. [INFO] +- org.springframework:spring-test:jar:3.0.6.RELEASE:test
  87. [INFO] +- org.springframework:spring-asm:jar:3.0.6.RELEASE:compile
  88. [INFO] +- org.slf4j:jcl-over-slf4j:jar:1.5.8:runtime
  89. [INFO] | \- (org.slf4j:slf4j-api:jar:1.5.8:runtime - omitted for conflict with 1.6.1)
  90. [INFO] +- org.slf4j:slf4j-api:jar:1.5.8:runtime (scope not updated to compile)
  91. [INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.8:runtime
  92. [INFO] | +- (org.slf4j:slf4j-api:jar:1.5.8:runtime - omitted for duplicate)
  93. [INFO] | \- (log4j:log4j:jar:1.2.14:runtime - omitted for duplicate)
  94. [INFO] +- junit:junit:jar:4.9:compile
  95. [INFO] | \- org.hamcrest:hamcrest-core:jar:1.1:compile
  96. [INFO] +- javassist:javassist:jar:3.12.1.GA:compile
  97. [INFO] +- com.sun.faces:jsf-impl:jar:2.1.3:compile
  98. [INFO] +- com.sun.faces:jsf-api:jar:2.1.3:compile
  99. [INFO] +- javax.servlet:jstl:jar:1.2:compile
  100. [INFO] +- javax.inject:javax.inject:jar:1:compile
  101. [INFO] +- javax.servlet:servlet-api:jar:3.0-alpha-1:provided (scope not updated to compile)
  102. [INFO] +- javax.servlet.jsp:jsp-api:jar:2.2.1-b03:provided
  103. [INFO] +- com.sun.el:el-ri:jar:1.0:provided
  104. [INFO] \- org.springframework:spring:jar:2.5.6.SEC03:compile
  105. [INFO] \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.1)
  106. [INFO] ------------------------------------------------------------------------
  107. [INFO] BUILD SUCCESSFUL
  108. [INFO] ------------------------------------------------------------------------
  109. [INFO] Total time: 2 seconds
  110. [INFO] Finished at: Sun Sep 25 23:21:18 CEST 2011
  111. [INFO] Final Memory: 16M/39M
  112. [INFO] ------------------------------------------------------------------------

这是hibernate jar文件重复的问题.但我不确定哪一个在这里重复.我的测试类正在执行.即tomcat的问题.

pom.xml中:

  1. MysqLMysqL-connector-java
最佳答案
  1. [INFO] +- org.hibernate:hibernate-core:jar:3.6.7.Final:compile
  2. [INFO] | +- org.hibernate:hibernate:jar:3.2.5.ga:compile

这些(至少)相互排斥.我使用“至少”,因为在您实施排除规则后,您需要重新检查您的依赖项.

我会排除较旧的3.2.5.ga.在org.springframework的依赖项中使用maven排除机制:spring-hibernate3:jar:2.0.8:compile.

猜你在找的Spring相关文章