浏览 10001 次
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2007-06-11
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" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://localhost:3306/cms"></property> <property name="username" value="root"></property> <property name="password" value="root"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </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" class="com.sea.user.dao.BaseDAO"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="userDAO" class="com.sea.user.dao.impl.UserDAO" parent="baseDAO" > </bean> <bean id="userService" class="com.sea.user.service.impl.UserService"> <property name="userDAO"> <ref bean="userDAO"/> </property> </bean> <bean id="userAction" class="com.sea.user.action.UserAction"> <property name="userService"> <ref bean="userService"/> </property> </bean> </beans> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-06-11
没有配置声明性事务,找个入门文章看下吧
|
|
返回顶楼 | |
发表时间:2007-06-11
好了, 但还不知道什么原因。代码也没有改动,莫明的就可以了。感觉是 IE 里的缓存吧。比较郁闷啊
|
|
返回顶楼 | |