question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SqlSessionTemplate bean is not valid for disposal by Spring container

See original GitHub issue

Spring 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:closed
  • Created 8 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mr-serjeycommented, Mar 3, 2016

Fixed in org.mybatis:mybatis-spring:1.2.4

0reactions
oyvindstegardcommented, Feb 11, 2016

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.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found