---
title: "No CurrentSessionContext configured"
author: "sjsky"
date: "2011-06-19T22:59:14Z"
tags: ["CurrentSessionContext", "Exception", "Hibernate", "Java"]
categories: ["编程语言"]
slug: "no-currentsessioncontext-configured"
draft: false
lastmod: "2012-02-20T10:14:13Z"
id: 1097989
url: "https://sjsky.iteye.com/blog/1097989"
---

blog迁移至 :[http://www.micmiu.com](http://www.micmiu.com/)

 

hibernate 配置启动报错，错误信息如下：

 

```
org.hibernate.HibernateException: No CurrentSessionContext configured!
	at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:540)
	at michael.jdbc.c3p0.C3p0HibernateExample.main(C3p0HibernateExample.java:31)
```

 

解决办法：在配置文件：hibernate.cfg.xml 添加属性：current\_session\_context\_class

 

```
<property name="current_session_context_class">thread</property>
```

 

 

 

转载请注明来自：Michael's blog @ [http://sjsky.iteye.com](/admin/)

-----------------------------------分 ------------------------------------隔 ------------------------------------线 --------------------------------------