开发者社区> 问答> 正文

spring mvc4和hibernate4整合问题?报错

最近想整个最新的springMvc版本,启动遇到这个报错,项目还是能正常启动,找了好久也找不出问题所在啊。。。

求高人指点!

报错信息如下:

2014-04-10 00:43:53,464 ERROR [org.hibernate.impl.SessionFactoryImpl] - <Unable to construct current session context [org.springframework.orm.hibernate4.SpringSessionContext]>

java.lang.NoSuchMethodException: org.springframework.orm.hibernate4.SpringSessionContext.<init>(org.hibernate.engine.SessionFactoryImplementor)

at java.lang.Class.getConstructor0(Class.java:2810)

at java.lang.Class.getConstructor(Class.java:1718)

at org.hibernate.impl.SessionFactoryImpl.buildCurrentSessionContext(SessionFactoryImpl.java:1002)

at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:334)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)

at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:339)

at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:427)

at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:412)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:681)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)

at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:381)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)

at java.util.concurrent.FutureTask.run(FutureTask.java:262)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:744)

2014-04-10 00:43:53,640 INFO [org.springframework.web.context.ContextLoader] - <Root WebApplicationContext: initialization completed in 1396 ms>


展开
收起
爱吃鱼的程序员 2020-06-22 10:53:55 616 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    配置事务

    回复 @RAY_STONE:hibernate4的session是与线程绑定的,与hibernate3是不一样的方式又是一轮调试,发现问题出在<propkey="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop>改成thread或jta就正常,难道是SpringSessionContext版本还没适配好?

    引用来自“贰狮叔”的评论

    配置事务

    把你的3个配置文件贴出来看一下?application,spring-mvc,web.xml

    springmvc4?我操,你升级升的真勤奋.

    呵呵,想重新搞一套,就整了个最新的楼主你的spring4能否借我参详一下,不甚感激。麻烦楼主发我邮箱345129564@qq.com。在在下感激不尽。最近公司可能要要最近太忙,才看到,还有需要吗?
    2020-06-23 11:59:42
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云栖社区特邀专家徐雷Java Spring Boot开发实战系列课程(第20讲):经典面试题与阿里等名企内部招聘求职面试技巧 立即下载
微服务架构模式与原理Spring Cloud开发实战 立即下载
阿里特邀专家徐雷Java Spring Boot开发实战系列课程(第18讲):制作Java Docker镜像与推送到DockerHub和阿里云Docker仓库 立即下载

相关实验场景

更多