异常:java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession

使用mybatis-3.2.2.jar + mybatis-spring-1.2.0.jar集成时,报以下异常:

15:42:48.538 [Thread-1] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy method ‘close‘ on bean with name ‘sqlSession‘
15:42:48.586 [Thread-1] WARN  o.s.b.f.s.DisposableBeanAdapter - Invocation of destroy method ‘close‘ failed on bean with name ‘sqlSession‘
java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession
    at org.mybatis.spring.SqlSessionTemplate.close(SqlSessionTemplate.java:306) ~[mybatis-spring-1.2.0.jar:1.2.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_11]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_11]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_11]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_11]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:327) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:510) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:486) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:740) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:455) [spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1090) [spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1064) [spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:980) [spring-context-3.2.3.RELEASE.jar:3.2.3.RELEASE]
15:42:48.586 [Thread-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean ‘com.pinganfu.common.log.SQLLogInterceptor#1bbf683‘: [sqlSessionFactory]
15:42:48.586 [Thread-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Retrieved dependent beans for bean ‘com.pinganfu.common.pagination.MySql5Dialect#c8211c‘: [com.pinganfu.common.pagination.PaginationInterceptor#76c8cd]
15:42:48.586 [Thread-1] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy method ‘close‘ on bean with name ‘dataSource‘

参考这里

http://code.google.com/p/mybatis/issues/detail?id=778

SqlSessionTemplate你不可以手动关闭。SqlSessionTemplate是一个代理类,内部他会为每次请求创建线程安全的sqlsession,并与Spring进行集成.在你的方法调用完毕以后他会自动关闭的。

时间: 2024-10-12 12:25:15

异常:java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession的相关文章

Manual close is not allowed over a Spring managed SqlSession

Manual close is not allowed over a Spring managed SqlSession 整合spring与MyBatis时出现如下警告: [org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:360)]-[WARN] Invocation of destroy method 'clo

java 异常java.lang.UnsupportedOperationException

在项目中采用一个枚举的集合,本人采用Collections中的空集合Collections.emptyList()在添加时发生异常: 常见集合如下: private List<VacationCategory> vacationcategorys = Collections.emptyList(); 报错误如下: -- Encapsulated exception ------------\java.lang.UnsupportedOperationException at java.util

Expected one result (or null) to be returned by selectOne(), but found: 2 和 java.lang.UnsupportedOperationException异常

在学习MyBatis的时候,简简单单的MyBatis+MySql的增删改查操作,但是却出了问题. 刚开始数据库只有一条数据的时候,岁月静好,一切看起来都那么的OJBK.但是,当我往数据库插入第二条数据的时候, 再次查询所有数据的时候, 却出现了Expected one result (or null) to be returned by selectOne(), but found: 2 这个异常,好吧,既然你说了期望一条,那么我用List来接收把. 却出现了这个异常java.lang.Unsu

Hbase delete遇到的常见异常: Exception in thread &quot;main&quot; java.lang.UnsupportedOperationException

hbase 执行批量删除时出现错误: Exception in thread "main" java.lang.UnsupportedOperationException at java.util.AbstractList.remove(AbstractList.java:161) at org.apache.hadoop.hbase.client.HTable.delete(HTable.java:852) 这种异常其实很常见,remove操作不支持,为什么会出现不支持的情况呢?检查

java.lang.UnsupportedOperationException

在使用Arrays.asList()后调用add,remove这些method时出现java.lang.UnsupportedOperationException异常.这是由于Arrays.asList() 返回java.util.Arrays$ArrayList, 而不是ArrayList.Arrays$ArrayList和ArrayList都是继承AbstractList,remove,add等method在AbstractList中是默认throw UnsupportedOperation

java.lang.UnsupportedOperationException: Not supported by BasicDataSource

场景: SpringMVC+Hibernate+Maven 问题: 在src/main/resources 目录中添加hibernate.properties文件, 则如果存在这句hibernate.hbm2ddl.auto=update 启动tomcat就报如下异常, 去掉启动不报错,访问servlet的时候报错,去掉文件中所有属性,访问也不报错hibernate.properties 文件内容:hibernate.connection.driver_class=com.mysql.jdbc.

java.lang.UnsupportedOperationException: Can&#39;t convert to integer: type=0x3

前几天在编写一个自定义控件的时候,出现了这个这个异常: Caused by: java.lang.UnsupportedOperationException: Can't convert to integer: type=0x3 然后定位到代码中的时候,发现是自定义控件中引用资源的时候报的错误,代码片段如下: int iconId = mTypedArray.getInteger(R.styleable.TitleBar_icon, 0); iconIv.setImageResource(ico

关于Mybatis的java.lang.UnsupportedOperationException异常处理

圈住的那行报java.lang.UnsupportedOperationException这个错,这个错的意思是:不支持的操作异常 异常我就不贴了,直接上解决办法吧. 可能我的异常跟大家的不太一样,报了这个异常时百度了很久,得到的解决大致都是:遍历List集合时不能做删除操作,要用迭代器等等,但仔细看我的也没有类似的操作啊! 只是做了一个简单的查询...最后发现问题所在: **Dao . xml : 如果你的返回值类型和我一样是List<String>,千万别这样接收,改为String,在Da

Arrays.asList引起的java.lang.UnsupportedOperationException解决方法

在项目中对List进行操作时报错java.lang.UnsupportedOperationException,后来发现操作的List是由数组转换而成的,通过看源码发现问题,并写测试程序如下. 代码块: public class ListTest { public static void main(String[] args) { String[] array = {"1","2","3","4","5"}