大神都来看看吧!!!-Could not obtain transaction-synchronized Session for current thread

hackcoder 2015-01-15 11:54:18
异常情况:
Exception in thread "taskExecutor-1" org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:134)
at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014)
at cn.uihome.hibernate.dao.HibernateGenericDao.getCurrentSession(HibernateGenericDao.java:73)
at cn.uihome.hibernate.dao.HibernateGenericDao.save(HibernateGenericDao.java:106)
at cn.uihome.hibernate.basedao.BaseDao.save(BaseDao.java:187)
at cn.uihome.service.noification.NotificationCommentManager.addNotificationComment(NotificationCommentManager.java:45)
at cn.com.guju.util.notification.NotificationCommentUtil.updateNotification(NotificationCommentUtil.java:123)
at cn.com.guju.util.notification.NotificationCommentUtil.addNotificationForCommented(NotificationCommentUtil.java:101)
at cn.com.guju.aop.task.activity.AsyncActivityTask.run(AsyncActivityTask.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

我是想在action里 开启一个新的线程,但这个线程涉及到Hibernate数据库的操作,所以报这个问题,求救大神给解决啊!!!!!!
...全文
17182 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jvmyes 2018-06-01
  • 打赏
  • 举报
回复
找了一大圈,终于找到答案了,我是springmvc+hibernate, mvc的注解配置太宽了,没有指定到controller层,修改base package,立刻解决,困扰了我很长时间,感谢感谢 @GW_Cheng
小小白龙马 2016-09-05
  • 打赏
  • 举报
回复
GW_Cheng 2016-05-04
  • 打赏
  • 举报
回复
我也遇到过这个问题,我的是在Controller中的扫描路径错了,如果在Controller中也扫描了Service,这个时候的Service是没有事务特性的,所以会报错。 解决方案就是不要在Controller中扫描事务相关的Service。 参考 http://blog.csdn.net/frankcheng5143/article/details/51308344 看能不能解决你的问题
hackcoder 2015-10-14
  • 打赏
  • 举报
回复
<filter> <filter-name>hibernateFilter</filter-name> <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class> <init-param> <param-name>singleSession</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>flushMode</param-name> <param-value>AUTO</param-value> </init-param> </filter> <filter-mapping> <filter-name>hibernateFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
练岩 2015-02-04
  • 打赏
  • 举报
回复
LZ解决了没有?怎么解决的?求教

5,655

社区成员

发帖
与我相关
我的任务
社区描述
Web开发应用服务器相关讨论专区
社区管理员
  • 应用服务器社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧