Intermittent issue with org.apache.ibatis.executor.ExecutorException: Cannot get Configuration as configuration factory was not set.

117 views
Skip to first unread message

Loïc MATHIEU

unread,
Aug 11, 2016, 11:00:29 AM8/11/16
to mybatis-user
Hello,

In one of our REST webservices that uses mybatis and mybatis-spring we're seeing intermittent failures (like one in a tens of thousands of the same calls) on mybatis : 
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)

I had the same issue with different versions of mybatis, mybatis-spring and CGLIB, so it don't seems to be linked to a library mismatched version.

Disabling the lazyloading features solved the issue.

It appears to have a race issue somewhere in ResultLoadeMap but I cannot figure it by myself.
I wanted to open a bug in Github but as I cannot reproduce the issue easily I didn't do it yet, that's why I reported the issue here.

Regards,

Loïc

Iwao AVE!

unread,
Aug 12, 2016, 7:40:31 AM8/12/16
to mybatis-user
Hi Loïc,

I don't know much about lazy loading, but do you specify 'configurationFactory' in your MyBatis config?

Regards,
Iwao


--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Loïc MATHIEU

unread,
Aug 16, 2016, 8:12:37 AM8/16/16
to mybatis-user
Hello,

No I didn't specify a 'configurationFactory' in my MyBatis config file, in fact I cannot see this property in the documentation : http://www.mybatis.org/mybatis-3/configuration.html
As I said, it works for 10000 calls then fails on one calls then works for 10000 other calls and deactivating the lazyloading functionality solved the issue. So I'm pretty sure that the issue is on the lazyloading code where some race situation occurs (there's some 'non-trheadsafe related comment in the code where the issue occurs).

Regards,
Loïc
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.

Iwao AVE!

unread,
Aug 16, 2016, 11:51:28 AM8/16/16
to mybatis-user
Hi,

I also think it's lazy-loading related.

configurationFactory was added as a part of this PR.
(and there is an open ticket for writing documentation https://github.com/mybatis/mybatis-3/issues/507 )

I could reproduce the exception by removing 'configurationFactory' setting from the following test case's config.

Guessing from the issue comment and the test case, the exception is thrown when you 1) lazy-load some property after serializing/de-serializing the parent object and 2) 'configurationFactory' was not set.
As this feature does not seem to be optional, you may have to provide configurationFactory which is just a class with a method named getConfiguration returning Configuration instance.

Please let me know if you get this exception without performing any (de)serialization on the related objects.

Regards,
Iwao


To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user+unsubscribe@googlegroups.com.

Loïc MATHIEU

unread,
Aug 16, 2016, 12:06:22 PM8/16/16
to mybatis-user
Hello,

Both issues are really old ones!

I'm not performing any serialization/deserailization, we use jackson to map to json our objects loading from mybatis that's all.

Regards,

Loîc

Iwao AVE!

unread,
Aug 18, 2016, 8:16:21 AM8/18/16
to mybatis-user
Hi, thanks for the info!

I'll try to find the cause, but it could be tricky without reproducing the issue.
If you could provide a small project demonstrating your lazy-loading use case, it would be very much appreciated (even if the issue is not reproducible with it).

And maybe you should set the configurationFactory and see how the situation changes.
With Spring, Configuration can be obtained via injected SqlSession.

Regards,
Iwao

To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user+unsubscribe@googlegroups.com.

Iwao AVE!

unread,
Dec 1, 2016, 9:18:45 AM12/1/16
to mybatis-user
Hi Löic,

Sorry for a late reply.

The EnhancedDeserializationProxyImpl class appeared in the stack trace is created on deserialization via readResolve() method, so the object was serialized/deserialized at some point in your solution, it seems.
Sometimes, containers or other frameworks perform serialization implicitly.

Regards,
Iwao

Iwao AVE!

unread,
Mar 4, 2017, 12:39:39 PM3/4/17
to mybatis-user
Allow me to bump an old thread for future reference.

I totally missed it, but some cache implementations perform serialization depending on the configuration.

// Iwao
Reply all
Reply to author
Forward
0 new messages