java.lang.annotation.IncompleteAnnotationException: org.terracotta.statistics.Statistic missing element type

3.1k Views Asked by At

My project have hibernate l2 cache and using ehcache for manage that with this configuration

hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory

After migrate to Spring boot 2 I get this exception

Caused by: java.lang.annotation.IncompleteAnnotationException: org.terracotta.statistics.Statistic missing element type
    at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:81)
    at com.sun.proxy.$Proxy151.type(Unknown Source)
    at org.terracotta.statistics.StatisticsManager.parseStatisticAnnotations(StatisticsManager.java:114)
    at org.terracotta.context.ContextManager.contextCreated(ContextManager.java:183)
    at org.terracotta.context.ContextManager.getOrCreateTreeNode(ContextManager.java:136)
    at org.terracotta.context.ContextManager.associate(ContextManager.java:114)
    at org.terracotta.context.ContextManager.access$000(ContextManager.java:38)
    at org.terracotta.context.ContextManager$1.withChild(ContextManager.java:57)
    at org.terracotta.statistics.StatisticsManager.createOperationStatistic(StatisticsManager.java:55)
    at org.terracotta.statistics.StatisticsManager.createOperationStatistic(StatisticsManager.java:50)
    at net.sf.ehcache.statistics.StatisticBuilder$OperationStatisticBuilder.build(StatisticBuilder.java:79)
    at net.sf.ehcache.Cache.<init>(Cache.java:268)
    at net.sf.ehcache.config.ConfigurationHelper.createCache(ConfigurationHelper.java:305)
    at net.sf.ehcache.config.ConfigurationHelper.createDefaultCache(ConfigurationHelper.java:223)
    at net.sf.ehcache.CacheManager.configure(CacheManager.java:783)
    at net.sf.ehcache.CacheManager.doInit(CacheManager.java:470)
    at net.sf.ehcache.CacheManager.init(CacheManager.java:394)
    ... 42 common frames omitted

After ask some question i found that both ehcache 2x and 3 x have in my project and exception cause is that , but when exclude 2x .see spring need to start 2 x .How can reolve this problem

2

There are 2 best solutions below

0
On BEST ANSWER

Fixed this this issue by replacing:

    <dependency>
        <groupId>org.ehcache</groupId>
        <artifactId>ehcache</artifactId>
    </dependency>

With the following:

   <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
    </dependency>

AS OF SPRING BOOT 2.0.2

remove:

spring.jpa.properties.hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.EhCacheRegionFactory

remove:

    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
    </dependency>
1
On

Fixed the issues by using,

<dependency>
    <groupId>org.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>3.0.0</version>
</dependency>