SqlSessionTemplate bean is not valid for disposal by Spring container
See original GitHub issueSpring can not dispose that bean gently because it uses close method of closable
public class SqlSessionTemplate implements SqlSession {
...
@Override
public void close() {
throw new UnsupportedOperationException("Manual close is not allowed over a Spring managed SqlSession");
}
...
Bean definition:
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
Exception appears:
08:22:09.665 [Thread-6] 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.7.0_67]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_67]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_67]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_67]
at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:327) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:510) [spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
No scoped proxy for SqlSessionTemplate with Spring ...
To do so, I would simply want to wrap the SqlSessionTemplate (which is the non-serializable thing) via Java config into a scoped proxy....
Read more >SqlSessionTemplate | mybatis-spring
Constructs a Spring managed SqlSession with the given SqlSessionFactory and ExecutorType . Public Methods. void, clearCache(). void, close().
Read more >Index (mybatis-spring 2.0.4 API)
Create a SqlSessionTemplate for the given SqlSessionFactory. ... Specifies a custom MapperFactoryBean to return a mybatis proxy as spring bean.
Read more >MyBatis-Spring 1.2.4版发布- 动态语言- ITPUB论坛
SqlSessionTemplate bean is not valid for disposal by Spring container added possibility to apply mapperInterface to MapperFactoryBean via .
Read more >MyBatis-Spring 1.2.4 正式发布 - 深度开源
Add vfsImpl property in SqlSessionFactoryBean. SqlSessionTemplate bean is not valid for disposal by Spring container. added possibility to apply mapperInterface ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed in org.mybatis:mybatis-spring:1.2.4
Seeing this issue here as well, on shutdown. Spring 4.2.4, mybatis 3.3.0 and mybatis-spring 1.2.3. Happens in JBoss as well as Jetty, so probably not dependent on server/container.