`

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"
		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>
	 


分享到:
评论
2 楼 pxysea 2007-06-11  
好了, 但还不知道什么原因。代码也没有改动,莫明的就可以了。感觉是 IE 里的缓存吧。比较郁闷啊
1 楼 dennis_zane 2007-06-11  
没有配置声明性事务,找个入门文章看下吧

相关推荐

    org.hibernate.HibernateException: No Hibernate Session bound to thread

    然而,在使用 Hibernate 进行数据库操作时,经常会遇到 "No Hibernate Session bound to thread" 的错误信息。本文将详细介绍该错误的解决方案。 错误原因 "No Hibernate Session bound to thread" 错误信息通常是...

    Hibernate-nosession

    然而,在某些特定场景下,我们可能并不需要频繁地打开和关闭Session,这时“Hibernate-nosession”就显得尤为重要。本文将深入探讨Hibernate-nosession的概念、应用场景以及如何在实际代码中实现。 首先,理解什么...

    Hibernate Session释放模式

    在Java的持久化框架Hibernate中,Session对象是与数据库交互的核心组件,它负责管理对象的持久状态。在处理大量数据或者长时间运行的事务时,合理地管理Session的生命周期至关重要,这就涉及到了Hibernate的Session...

    OA系统整体设计及约定、搭建环境.rar_OA系统及配置_OA系统整体设计及约定、搭建环境_creation

    hibernate就会抛出: No Hibernate Session bound to thread, and configuration does not allow creation of one here}异常。 在实际的SSH web应用开发中,我们通常用spring来进行事务的管理。我们一般不会在dao层...

    JAVA错误文档.pdf

    4. Hibernate框架错误:文档还包含了“org.hibernate.HibernateException: No Hibernate Session bound to thread”等错误信息,这是Hibernate框架常见的异常,表明在当前线程上没有绑定Hibernate Session。...

    hibernate_reference使用指南全

    Hibernate 的架构主要包括 SessionFactory、Session、Transaction 等核心组件,这些组件共同构成了 Hibernate 的工作流程。 - **2.2 实例状态** Hibernate 支持多种实例状态,包括持久化状态、瞬态状态和分离...

    使用Hibernate一些常见错误解决办法

    当遇到`no current session bound to current context`错误时,通常是因为事务管理方式不正确。Hibernate提供了多种会话上下文配置,如`thread`、`jta`等。在这种情况下,推荐使用`thread`配置,确保每个线程都有...

    Spring+hibernate+quartz 定时操作数据库

    在spring+hibernate的框架中定时操作数据库,主要是拿到sessionFactory,不会出现no session 和transaction no-bound等问题,由sessionFactory完成对数据的操作,有些包是没有用的,有兴趣的可以自己删除掉

    PDO版本问题 Invalid parameter number: no parameters were bound

    然而,当遇到"Invalid parameter number: no parameters were bound"错误时,这意味着尝试执行的SQL语句中的占位符参数没有正确地与实际值绑定。 这个问题在某些旧版本的PHP和PDO中被报告为一个bug,特别是...

    Hibernate Reference Documentation3.1

    1. Introduction to Hibernate 1.1. Preface 1.2. Part 1 - The first Hibernate Application 1.2.1. The first class 1.2.2. The mapping file 1.2.3. Hibernate configuration 1.2.4. Building with Ant 1.2.5. ...

    数据池连接Name jdbc is not bound in this Context解决方案

    如果仍然遇到“Name jdbc is not bound in this Context”的错误,可能的原因包括:配置文件未正确放置、配置错误、JDBC驱动未包含在应用的类路径中,或者Tomcat服务未成功读取和解析配置文件。解决这类问题通常需要...

    swoole#swoole-wiki#3.13.4 - 错误信息: XXXX client has already been b

    错误信息: XXXX client has already been bound to another coroutine使用协程客户端时出现以下错误信息:re

    Hibernate 3.x 参考手册

    - **Hibernate 是什么?** - 开源 ORM (Object-Relational Mapping) 框架。 - 用于简化 Java 应用程序中数据库访问逻辑。 **2.2 第一个 Hibernate 应用程序** - **第一步:创建第一个类** - 定义简单的 POJO 类...

    JavaBean - Bound属性

    在JavaBean中,"Bound属性"是指那些当其值发生改变时,能够自动通知相关监听器和其他依赖组件的属性。这种特性使得JavaBean在Java应用程序和网页设计中(如JSP)特别有用,因为它简化了组件之间的交互。 在JavaBean...

    Android Service之bound实现

    本文将深入探讨“Android Service之bound实现”,理解如何通过绑定服务(Bound Service)来创建一个与应用程序组件交互的服务。 首先,我们要了解服务的两种基本类型:Start Service和Bound Service。Start Service...

    usb-bound分析器

    "USB-bound分析器"是一款专为USB设备监测和分析设计的工具,主要功能是帮助用户查看和理解系统中连接的USB设备的相关信息。通过这款软件,你可以深入洞察USB设备的工作状态,了解USB协议的交互过程,这对于系统管理...

    spring分别与jdbc和hibernate结合的事务控制--案例

    本案例重点探讨了Spring如何与两种流行的数据访问技术——JDBC(Java Database Connectivity)和Hibernate——相结合,进行事务管理。事务控制是确保数据库操作一致性、完整性的关键,尤其在多步骤操作中,它能防止...

    Tomcat启动时报错:Name salesDataSource is not bound in this Context

    Name salesDataSource is not bound in this Context,连接池的问题

    lower-bound函数1.zip

    std::cout &lt;&lt; "No element found greater than or equal to " &lt;&lt; value_to_find ; } return 0; } ``` 这段代码会输出:“No element found greater than or equal to 5”,因为5不在`vec`中。 总的来说,`...

Global site tag (gtag.js) - Google Analytics