首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

No Hibernate Session bound to thread 是什么缘故

2013-11-09 
No Hibernate Session bound to thread 是什么原因2:22:11,640 ERROR [default]:250 - Servlet.service()

No Hibernate Session bound to thread 是什么原因
2:22:11,640 ERROR [default]:250 - Servlet.service() for servlet default threw exception
java.lang.IllegalStateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:350)
at org.springframework.orm.hibernate3.SessionFactoryUtils.getSession(SessionFactoryUtils.java:200)
at com.sea.user.dao.BaseDAO.getSession(BaseDAO.java:23)
at com.sea.user.dao.impl.UserDAO.saveUser(UserDAO.java:16)
at com.sea.user.service.impl.UserService.saveUser(UserService.java:14)
at com.sea.user.action.UserAction.register(UserAction.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


请解决一下,谢谢!

这是BaseDAO内容

public class BaseDAO {private SessionFactory sessionFactory;public SessionFactory getSessionFactory() {return sessionFactory;}public void setSessionFactory(SessionFactory sessionFactory) {this.sessionFactory = sessionFactory;}public Session getSession(){Session session = sessionFactory.openSession();return session;}}

applicationContext.xml 文件配置
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"><bean id="dataSource"value="jdbc:mysql://localhost:3306/cms"></property><property name="username" value="root"></property><property name="password" value="root"></property></bean> <bean id="sessionFactory"/></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop><prop key="hibernate.show_sql">false</prop></props></property><property name="mappingResources"><list><value>com/sea/user/vo/Users.hbm.xml</value><value>com/sea/user/vo/Usersdetail.hbm.xml</value></list></property></bean> <bean id="baseDAO" parent="baseDAO" ></bean><bean id="userService" /> 但还不知道什么原因。代码也没有改动,莫明的就可以了。感觉是 IE 里的缓存吧。比较郁闷啊 

热点排行