lemonzone2010 / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

net.sf.ehcache.transaction.TransactionException: transaction not started #402

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
After adding javamelody to our project, I see lots of these exceptions in the 
log:

net.sf.ehcache.transaction.TransactionException: transaction not started
    at net.sf.ehcache.transaction.local.LocalTransactionStore.getCurrentTransactionContext(LocalTransactionStore.java:108) ~[ehcache-core-2.6.5.jar:na]
    at net.sf.ehcache.transaction.local.LocalTransactionStore.assertNotTimedOut(LocalTransactionStore.java:114) ~[ehcache-core-2.6.5.jar:na]
    at net.sf.ehcache.transaction.local.LocalTransactionStore.assertNotTimedOut(LocalTransactionStore.java:130) ~[ehcache-core-2.6.5.jar:na]
    at net.sf.ehcache.transaction.local.LocalTransactionStore.getSize(LocalTransactionStore.java:543) ~[ehcache-core-2.6.5.jar:na]
    at net.sf.ehcache.Cache.getSize(Cache.java:2588) ~[ehcache-core-2.6.5.jar:na]
    at net.sf.ehcache.Cache.getSizeBasedOnAccuracy(Cache.java:2598) ~[ehcache-core-2.6.5.jar:na]
    at net.sf.ehcache.Cache.getStatistics(Cache.java:3077) ~[ehcache-core-2.6.5.jar:na]
    at net.bull.javamelody.CacheInformations.<init>(CacheInformations.java:79) ~[javamelody-core-1.50.0.jar:1.50.0]
    at net.bull.javamelody.CacheInformations.buildCacheInformationsList(CacheInformations.java:165) ~[javamelody-core-1.50.0.jar:1.50.0]
    at net.bull.javamelody.JavaInformations.<init>(JavaInformations.java:188) [javamelody-core-1.50.0.jar:1.50.0]
    at net.bull.javamelody.MonitoringController.doActionIfNeededAndReport(MonitoringController.java:141) [javamelody-core-1.50.0.jar:1.50.0]
    at net.bull.javamelody.MonitoringFilter.doMonitoring(MonitoringFilter.java:348) [javamelody-core-1.50.0.jar:1.50.0]
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:171) [javamelody-core-1.50.0.jar:1.50.0]

I couldn't find anything in the documentation regarding ehcache and 
transactions.

Original issue reported on code.google.com by adigu...@gmail.com on 11 Apr 2014 at 8:02

GoogleCodeExporter commented 9 years ago
It seems to be caused by transactionalMode="local" in your ehcache 
configuration (ehcache.xml file). And it seems to me that this mode is quite 
rare.

If javamelody needs to be changed, this may be to replace in the 
CacheInformations constructor from:
final Statistics statistics = cache.getStatistics();

to:
final Statistics statistics;
if (cache.getCacheConfiguration().getTransactionalMode().isTransactional()) {
    final TransactionController transactionController = cache.getCacheManager()
            .getTransactionController();
    transactionController.begin();
    try {
        statistics = cache.getStatistics();
    } finally {
        transactionController.commit();
    }
} else {
    statistics = cache.getStatistics();
}

but just when the ehcache version used is recent enough.

Original comment by evernat@free.fr on 11 Apr 2014 at 9:02