Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread

org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
    org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:134)
    org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014)
    com.eric.cms.content.dao.UserDaoImpl.addUser(UserDaoImpl.java:21)
    com.eric.cms.content.service.UserServiceImpl.addUser(UserServiceImpl.java:21)
    com.eric.cms.content.controller.LoginController.login(LoginController.java:27)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:175)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)

原因:hibernate4不支持你用hibernate3的 getcurrentSession,建议你用openSession

时间: 2024-08-17 13:50:46

Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread的相关文章

SpringMVC4+Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread

查了一下相关资料,整理如下: 原因:Hibernate4 No Session found for current thread原因 解决方法: 1.  在spring 配置文件中加入  程序代码 <tx:annotation-driven transaction-manager="transactionManager"/> 并且在处理业务逻辑的类上采用注解  程序代码 @Service public class CustomerServiceImpl implements

部署CM集群首次运行报错:Formatting the name directories of the current NameNode.

1. 报错提示 Formatting the name directories of the current NameNode. If the name directories are not empty, this is expected to fail. 2. 问题原因 之前的namenode格式化了,所以这次不能格式化,需要把原来格式化的删除. 3. 解决方法 1)在/dfs目录下有dn或者nn [[email protected] dfs]# ls /dfs/ nn snn 删除三台机器

Hibernate4中使用getCurrentSession报Could not obtain transaction-synchronized Session for current thread

架个spring4+hibernate4的demo,dao层直接注入的sessionFactory,然后用getCurrentSession方法获取session,然后问题来了,直接报错: Could not obtain transaction-synchronized Session for current thread 提示无法获取当前线程的事务同步session,略微奇怪,这和事务有什么关系..然后百度一下有人说改成用openSession方法就好了,那我又百度了一下这2个方法的区别:

appium运行报错java.net.SocketException: socket write error

这个错我调了 快两天一点头绪没有,脚本正常跑没问题,但是就是控制台输出信息报错,没法定位问题在哪.报错如图: 虽然这个报错不影响测试结果,但是本人有强迫症,一定要查出究竟: 我的尝试: 1.那天试验,服务器上的代码没问题,我本地一运行就报这个错,结果我把系统重装了(先前我查了两个小时百度加上尝试,无果) 2.今天从中午开始又开始搞起来,起初怀疑是我的io操作引起的,结果在finanly加了process.destroy();及p.getErrorStream(),close也不行, 网上查了说是

dubbo-admin-2.5.3 运行报错: Bean property &#39;URIType&#39; is not writable or has an invalid

因为 jdk 是1.8的版本,和 dubbo-admin 存在兼容性问题.所以报错: Bean property 'URIType' is not writable or has an invalid 参见:https://github.com/alibaba/dubbo/issues/50 解决方法,修改 tomcat 默认的 jdk到 1.7 : 1) 修改bin文件夹下面的catalina.bat文件,把如下内容rem ----- Execute The Requested Command

解决新建Support7Demos的sample时出现编译错误和运行报错出现的问题

右键New->Other->Android Sample Project->选择Android 4.4.2->选择Support7Demos ,finish. 会出现编译错误 解决如下: 1.把这三个文件导入到Eclipse里, 这三个是库文件,并且勾选COPY到工作空间里选项 如果没有这三个文件,就从这里下载 2.导入三个library工程后,mediarouter会无法编译,打开工程属性在anroid里将api-level改成17,添加依赖工程appcompat 3.就是将刚才

windows 2003 64位系统php运行报错:1%不是有效的win32应用程序解决办法

windows 2003 64位系统php运行报错:1%不是有效的win32应用程序 解决办法:运行-CMD cscript c:\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

Oracle EBS-SQL (MRP-7):检查MRP计划运行报错原因之超大数据查询2.sql

The following scripts can be used to check for huge line numbers: -- PO Requisitions select * from PO_REQUISITION_LINES_ALL where LINE_NUM > 1000000000; -- PO Lines select * from PO_LINES_ALL where LINE_NUM > 1000000000; -- Receiving Supply SELECT *

Django 运行报错 ImportError: No module named &#39;PIL&#39;

importError: No module named pil WIN7 64位系统安装 Python PIL 首先通过easy_install安装 说找不到pil模块. 第二通过去官网找:http://www.pythonware.com/products/pil/ 找了几个版本安装版的没有64位的,源码包的下载无法安装说要安装vs2008我也安装了还是不行.最后在这个地址找到:http://www.lfd.uci.edu/~gohlke/pythonlibs/ Pillow is a re