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

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

错误信息:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
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
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.initializeBean(AbstractAutowireCapablebeanfactory.java:1338)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:473)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory$1.run(AbstractAutowireCapablebeanfactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBean(AbstractAutowireCapablebeanfactory.java:380)
    at org.springframework.beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:261)
    at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:185)
    at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:164)
    at org.springframework.beans.factory.support.DefaultListablebeanfactory.preInstantiateSingletons(DefaultListablebeanfactory.java:423)
    at org.springframework.context.support.AbstractApplicationContext.finishbeanfactoryInitialization(AbstractApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IncompatibleClassChangeError: Implementing class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
    at java.lang.Class.getConstructor0(Class.java:2714)
    at java.lang.Class.getDeclaredConstructor(Class.java:2002)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:78)
    at org.springframework.orm.hibernate3.LocalSessionfactorybean.newConfiguration(LocalSessionfactorybean.java:772)
    at org.springframework.orm.hibernate3.LocalSessionfactorybean.buildSessionFactory(LocalSessionfactorybean.java:517)
    at org.springframework.orm.hibernate3.AbstractSessionfactorybean.afterPropertiesSet(AbstractSessionfactorybean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.invokeInitMethods(AbstractAutowireCapablebeanfactory.java:1369)
    at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.initializeBean(AbstractAutowireCapablebeanfactory.java:1335)
    ... 23 more

使用tomcat 7和maven构建.

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

C:\project>mvn dependency:tree -Dverbose
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building home-app
[INFO]    task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree {execution: default-cli}]
[INFO] com.home.app:home-app:war:0.0.1
[INFO] +- org.springframework:spring-orm:jar:3.0.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
[INFO] |  |  \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- org.springframework:spring-jdbc:jar:3.0.5.RELEASE:compile
[INFO] |  |  +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  |  +- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  |  \- (org.springframework:spring-tx:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  \- (org.springframework:spring-tx:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] +- log4j:log4j:jar:1.2.14:runtime (scope not updated to compile)
[INFO] +- MysqL:MysqL-connector-java:jar:5.1.17:compile
[INFO] +- org.hibernate:ejb3-persistence:pom:3.3.2.Beta1:compile
[INFO] +- org.hibernate:hibernate-core:jar:3.6.7.Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.1:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] |  |  \- (org.slf4j:slf4j-api:jar:1.5.8:compile - omitted for conflict with 1.6.1)
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] |  +- javax.transaction:jta:jar:1.1:compile
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for conflict with 1.5.8)
[INFO] +- commons-dbcp:commons-dbcp:jar:1.2.2:compile
[INFO] |  \- commons-pool:commons-pool:jar:1.3:compile
[INFO] +- org.springframework:spring-hibernate3:jar:2.0.8:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.1:compile
[INFO] |  |  +- (log4j:log4j:jar:1.2.12:compile - omitted for conflict with 1.2.14)
[INFO] |  |  +- logkit:logkit:jar:1.0.1:compile
[INFO] |  |  +- avalon-framework:avalon-framework:jar:4.1.3:compile
[INFO] |  |  \- (javax.servlet:servlet-api:jar:2.3:compile - omitted for conflict with 3.0-alpha-1)
[INFO] |  +- org.hibernate:hibernate:jar:3.2.5.ga:compile
[INFO] |  |  +- net.sf.ehcache:ehcache:jar:1.2.3:compile
[INFO] |  |  |  +- (commons-logging:commons-logging:jar:1.0.4:compile - omitted for conflict with 1.
[INFO] |  |  |  \- (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict w
[INFO] |  |  +- (javax.transaction:jta:jar:1.0.1B:compile - omitted for conflict with 1.1)
[INFO] |  |  +- (commons-logging:commons-logging:jar:1.0.4:compile - omitted for conflict with 1.1)
[INFO] |  |  +- asm:asm-attrs:jar:1.5.3:compile
[INFO] |  |  +- (dom4j:dom4j:jar:1.6.1:compile - omitted for duplicate)
[INFO] |  |  +- (antlr:antlr:jar:2.7.6:compile - omitted for duplicate)
[INFO] |  |  +- (cglib:cglib:jar:2.1_3:compile - omitted for conflict with 2.2.2)
[INFO] |  |  +- (asm:asm:jar:1.5.3:compile - omitted for conflict with 3.3.1)
[INFO] |  |  \- (commons-collections:commons-collections:jar:2.1.1:compile - omitted for conflict wi
[INFO] |  +- (org.springframework:spring-beans:jar:2.0.8:compile - omitted for conflict with 3.0.5.R
[INFO] |  +- (org.springframework:spring-context:jar:2.0.8:compile - omitted for conflict with 3.0.5
[INFO] |  +- (org.springframework:spring-core:jar:2.0.8:compile - omitted for conflict with 3.0.5.RE
[INFO] |  +- org.springframework:spring-dao:jar:2.0.8:compile
[INFO] |  |  +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] |  |  +- (commons-logging:commons-logging:jar:1.1:compile - omitted for duplicate)
[INFO] |  |  +- (org.springframework:spring-beans:jar:2.0.8:compile - omitted for conflict with 3.0.
[INFO] |  |  +- (org.springframework:spring-context:jar:2.0.8:compile - omitted for duplicate)
[INFO] |  |  \- (org.springframework:spring-core:jar:2.0.8:compile - omitted for conflict with 3.0.5
[INFO] |  \- (org.springframework:spring-jdbc:jar:2.0.8:compile - omitted for conflict with 3.0.5.RE
[INFO] +- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
[INFO] |  \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
[INFO] |  +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-asm:jar:3.0.5.RELEASE:compile - omitted for conflict with 3
[INFO] |  +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
[INFO] |  +- (org.springframework:spring-aop:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-expression:jar:3.0.5.RELEASE:compile - omitted for duplicat
[INFO] |  \- (org.springframework:spring-asm:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-tx:jar:3.0.5.RELEASE:compile
[INFO] |  +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-aop:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-beans:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-context:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  \- (org.springframework:spring-core:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
[INFO] |  +- (org.springframework:spring-asm:jar:3.0.5.RELEASE:compile - omitted for duplicate)
[INFO] |  \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.1)
[INFO] +- cglib:cglib:jar:2.2.2:compile
[INFO] |  \- asm:asm:jar:3.3.1:compile
[INFO] +- org.springframework:spring-test:jar:3.0.6.RELEASE:test
[INFO] +- org.springframework:spring-asm:jar:3.0.6.RELEASE:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.5.8:runtime
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.5.8:runtime - omitted for conflict with 1.6.1)
[INFO] +- org.slf4j:slf4j-api:jar:1.5.8:runtime (scope not updated to compile)
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.8:runtime
[INFO] |  +- (org.slf4j:slf4j-api:jar:1.5.8:runtime - omitted for duplicate)
[INFO] |  \- (log4j:log4j:jar:1.2.14:runtime - omitted for duplicate)
[INFO] +- junit:junit:jar:4.9:compile
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:compile
[INFO] +- javassist:javassist:jar:3.12.1.GA:compile
[INFO] +- com.sun.faces:jsf-impl:jar:2.1.3:compile
[INFO] +- com.sun.faces:jsf-api:jar:2.1.3:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- javax.inject:javax.inject:jar:1:compile
[INFO] +- javax.servlet:servlet-api:jar:3.0-alpha-1:provided (scope not updated to compile)
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.2.1-b03:provided
[INFO] +- com.sun.el:el-ri:jar:1.0:provided
[INFO] \- org.springframework:spring:jar:2.5.6.SEC03:compile
[INFO]    \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.1)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Sun Sep 25 23:21:18 CEST 2011
[INFO] Final Memory: 16M/39M
[INFO] ------------------------------------------------------------------------

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

pom.xml中:

MysqLMysqL-connector-java
最佳答案
[INFO] +- org.hibernate:hibernate-core:jar:3.6.7.Final:compile
[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相关文章