MyBatis intermitent error : org.apache.ibatis.executor.ExecutorException: Cannot get Configuration as configuration factory was not set
<p>We're using mybatis with mybatis spring from a long time and we hit an intermittent issue with one of our application :</p>

<pre><code>org.apache.ibatis.executor.ExecutorException: Cannot get Configuration as configuration factory was not set.
    at org.apache.ibatis.executor.loader.ResultLoaderMap$LoadPair.getConfiguration(ResultLoaderMap.java:220)
    at org.apache.ibatis.executor.loader.ResultLoaderMap$LoadPair.load(ResultLoaderMap.java:191)
    at org.apache.ibatis.executor.loader.AbstractEnhancedDeserializationProxy.invoke(AbstractEnhancedDeserializationProxy.java:78)
    at org.apache.ibatis.executor.loader.cglib.CglibProxyFactory$EnhancedDeserializationProxyImpl.intercept(CglibProxyFactory.java:184)
</code></pre>

<p>The strange thing is that my applicaton, a REST service, is used by a lot of consumer for a long time and only recently, without changing anything in the code base, this issue occurs. It occurs when my REST service is called from a spring-batch application that calls it thousands of times successively. Calling directly the same service works. The error comes intermittently (not always the same URL).</p>

<p>MyBatis is in version 3.2.8 and mybatis-spring 1.0. I tried with more recent versions (MyBatis 3.4.1 and mybatis-spring 1.2.3) but the same error occurs.</p>

<p>There should be a strange issues occuring because of specific race condition or something else ... is someone already have the same issue? It can't be a configuration issue as the application is working fine and only fails intermittently.</p>

<p>Regards,</p>

<p>Loïc</p>