`

hibernate 整合spring 错误

 
阅读更多
hibernate 4.3.5+spring 3.2.4

java.lang.IllegalStateException: Failed to load ApplicationContext
	at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99)
	at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:122)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:312)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:284)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 't1Service' defined in file [H:\trunck\lotcenter\target\classes\com\taovo\lotcenter\local\service\T1Service.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TxAdvice': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in URL [file:/H:/trunck/lotcenter/target/classes/META-INF/spring/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider;
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:120)
	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100)
	at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:248)
	at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64)
	at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91)
	... 25 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'TxAdvice': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in URL [file:/H:/trunck/lotcenter/target/classes/META-INF/spring/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider;
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
	at org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor.getAdvice(AbstractBeanFactoryPointcutAdvisor.java:86)
	at org.springframework.aop.aspectj.AspectJProxyUtils.isAspectJAdvice(AspectJProxyUtils.java:66)
	at org.springframework.aop.aspectj.AspectJProxyUtils.makeAdvisorChainAspectJCapableIfNecessary(AspectJProxyUtils.java:49)
	at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.extendAdvisors(AspectJAwareAdvisorAutoProxyCreator.java:97)
	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:89)
	at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:69)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:409)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1488)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	... 39 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in URL [file:/H:/trunck/lotcenter/target/classes/META-INF/spring/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider;
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
	... 59 more
Caused by: java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getConnectionProvider()Lorg/hibernate/service/jdbc/connections/spi/ConnectionProvider;
	at org.springframework.orm.hibernate4.SessionFactoryUtils.getDataSource(SessionFactoryUtils.java:90)
	at org.springframework.orm.hibernate4.HibernateTransactionManager.afterPropertiesSet(HibernateTransactionManager.java:335)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
	... 66 more




错误原因:
原因,在使用Spring3.2.x与Hibernate4.3.x(4.1.7以上)的版本整合时出的错。
解决方案:把Hibernate降至4.1.7或以下的版本就行了。
http://sourceforge.net/projects/hibernate/files/hibernate4/
这是由Spring和Hibernate4.3.x版本兼容性的问题产生的
它的官方有如下说明:
https://jira.springsource.org/browse/SPR-10839
分享到:
评论

相关推荐

    Spring+hibernate整合源代码

    这个“Spring+hibernate整合源代码”应该包含了实现上述整合步骤的示例代码,可以作为学习和参考的资源。通过学习和实践这些代码,你可以更好地理解和掌握 Spring 和 Hibernate 整合的细节,提升你的 Java Web 开发...

    10.6struts2+hibernate+spring的整合源代码

    SSH(Struts2+Spring+Hibernate)框架整合是Java Web开发中常见的一种技术栈,能有效地提高开发效率和代码质量。 Struts2作为MVC框架,主要负责处理HTTP请求,控制应用程序的流程,提供视图和控制器的分离。它的...

    Spring整合Hibernate案例

    - 整合Spring和Hibernate的主要目的是利用Spring的管理能力,让Hibernate的DAO(数据访问对象)和SessionFactory可以通过Spring的IoC(控制反转)容器进行管理和注入,提高代码的可测试性和可维护性。 3. **整合...

    Struts+Spring+Hibernate整合练习

    5. **整合Spring和Hibernate**:在Spring配置文件中,配置Hibernate的SessionFactory,并创建DAO bean,注入SessionFactory。 在描述中,创建了一个简单的登录Action和对应的ActionForm,使用了DynaValidatorForm,...

    Struts2+Hibernate+Spring整合开发深入剖析与范例应用02

    这个"Struts2+Hibernate+Spring整合开发深入剖析与范例应用02"的学习资源,很可能是关于这三大框架集成使用的详细教程或案例集。02这个文件名可能代表系列的第二部分,意味着它可能在前一部分的基础上进一步深入讲解...

    struts2+spring+hibernate 整合的jar包

    Struts2、Spring和Hibernate是Java Web开发中的三大框架,它们的整合(SSH)极大地提升了开发效率和项目的可维护性。下面将详细讲解这三大框架的核心功能以及整合过程中的关键知识点。 1. **Struts2**:Struts2是一...

    struts2 spring hibernate整合的简单登录代码

    Struts2、Spring和Hibernate是Java Web开发中的三大框架,它们各自负责不同的职责:Struts2作为MVC框架处理请求和展示,Spring提供依赖注入和事务管理,Hibernate则作为ORM框架处理数据库操作。将这三个框架整合在...

    springMVC+hibernate+spring4.3 jar包整合

    整合Spring MVC、Hibernate 4和Spring 4.3的过程主要包括以下步骤: 1. 配置pom.xml:在Maven项目中,你需要添加这三个框架的依赖,确保所有必要的jar包都被引入。这些jar包包括但不限于spring-webmvc、spring-orm...

    tapestry5.3.3+spring+hibernate整合源码

    整合Tapestry、Spring和Hibernate,开发者可以利用它们各自的优点:Tapestry的组件化开发、Spring的依赖管理和事务控制,以及Hibernate的ORM能力。这样的组合可以构建出结构清晰、易于维护且具有高度可扩展性的Web...

    struts2 hibernate spring整合(出错的)

    总之,"struts2 hibernate spring整合(出错的)"意味着开发者可能在整合过程中遇到了困难,需要对每个框架的配置、相互间的配合以及常见的问题有深入理解,才能找出并修复错误。这通常需要对Java Web开发有扎实的基础...

    struts2 spring hibernate 整合

    【SSH整合】指的是Struts2、Spring和Hibernate这三个开源框架的集成应用,它们在JavaEE企业级开发中占据着重要地位。Struts2是一个MVC框架,负责处理用户请求和控制应用程序流程;Spring是一个全面的后端解决方案,...

    Spring整合HIbernate

    本文将深入探讨如何整合Spring和Hibernate,以实现数据访问层的优雅集成。 一、Spring对Hibernate的支持 Spring通过其JDBC抽象层和ORM模块提供了对Hibernate的全面支持。主要体现在以下几个方面: 1. **...

    搞定J2EE:STRUTS+SPRING+HIBERNATE整合详解与典型案例 (1)

    11.4 整合Spring和Struts 11.4.1 Spring和Struts的整合方式 11.4.2 编写实现登录的页面regedit.jsp 11.4.3 编写存储登录用户信息的类User.java 11.4.4 编写控制器RegeditAction.java 11.4.5 编写业务逻辑接口Regedit...

    spring-Hibernate整合代码测试过程

    总结起来,"spring-Hibernate整合代码测试过程"涉及了Spring框架的依赖注入、事务管理、以及与Hibernate的整合,同时也涵盖了Hibernate的实体映射、DAO设计和事务控制。通过这个过程,我们可以构建出一个高效、健壮...

    Flex+hibernate+spring整合

    4. **Hibernate整合**:Spring提供了对Hibernate的全面支持,包括Session工厂、事务管理和DAO(Data Access Object)模板。通过Spring,可以更容易地管理和控制Hibernate会话,减少代码复杂性。 5. **Model-View-...

    精通J2EE--Eclipse、Struts、Hibernate及Spring整合应用案例.pdf

    《精通J2EE--Eclipse、Struts、Hibernate及Spring整合应用案例》这本书主要涵盖了Java企业级开发中的四大核心技术:Eclipse集成开发环境、Struts框架、Hibernate持久化框架以及Spring框架。这些技术的组合通常被称为...

    springmvc, spring5.x , hibernate5.x 整合

    整合Spring MVC、Spring 5.x和Hibernate 5.x,我们可以构建一个强大的后端系统。首先,我们需要在Spring配置中声明Hibernate的DataSource和SessionFactory,然后通过Spring的JdbcTemplate或Hibernate的Session接口...

    基于struts+hibernate+spring的用户管理系统

    【基于Struts+Hibernate+Spring的用户管理系统】是一种常见的企业级Web应用架构,它整合了三个主流的Java技术框架,以构建高效、可维护性高的系统。Struts提供了MVC(Model-View-Controller)设计模式,使得业务逻辑...

    Struts+hibernate+spring学习实例

    7. 整合配置:在struts-config.xml、hibernate.cfg.xml和Spring的配置文件(如applicationContext.xml)中,正确配置各个组件,使它们能协同工作。 8. 错误和异常处理:设计合适的错误页面和异常处理器,处理可能...

    struts2+hibernate+spring整合

    【整合Struts2+Hibernate+Spring详解】 在Java Web开发中,使用Struts2、Hibernate和Spring进行整合是一个常见的架构模式,它可以帮助开发者构建高效、模块化的应用。本篇文章将详细解析这一整合过程,以及如何解决...

Global site tag (gtag.js) - Google Analytics