首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >simple-spring-memcached升级到4.1.1导致WrappedCacheException

simple-spring-memcached升级到4.1.1导致WrappedCacheException
EN

Stack Overflow用户
提问于 2018-11-21 15:02:25
回答 1查看 265关注 0票数 0

我最近将simple-spring-memcached从版本3.6.1升级到了4.1.1。然而,在这个版本升级之后,每当我的代码试图从缓存中获取一个值时,我都会得到WrappedCacheException。我在下面分享我的代码片段:

代码语言:javascript
复制
@Transactional
@Cacheable(value = CACHE_NAME, key = "#id")
@Override
public TicketModel validate(final String id) {
    TicketEntity ticketEntity = ticketEntityRepository.findOne(id);
    if (ticketEntity == null) {
        System.out.println("Ticket not found")
    }
    return something;
}

我的cacheManager bean看起来像这样:

代码语言:javascript
复制
@Bean
public CacheManager cacheManager() throws Exception {
    List<SSMCache> cacheList = new ArrayList<>();

    CacheFactory cacheFactory;
    if (ELASTIC_CACHE_FACTORY.equals(cacheBean)) {
        cacheFactory = elastiCacheFactory();
    } else {
        cacheFactory = memCacheFactory();
    }

    Cache cache = cacheFactory.getObject();

    SSMCache aamCache = new SSMCache(cache, cacheTimeout, true);
    cacheList.add(aamCache);

    SSMCacheManager cacheManager = new SSMCacheManager();
    cacheManager.setCaches(cacheList);
    cacheManager.afterPropertiesSet();
    return cacheManager;
}

我得到的确切异常如下所示:

代码语言:javascript
复制
    SEVERE: Servlet.service() for servlet [jersey-servlet] in context with path [/user-service-web] threw exception [com.google.code.ssm.spring.WrappedCacheException] with root cause
com.google.code.ssm.spring.WrappedCacheException
    at com.google.code.ssm.spring.SSMCache.logOrThrow(SSMCache.java:318)
    at com.google.code.ssm.spring.SSMCache.getValue(SSMCache.java:285)
    at com.google.code.ssm.spring.SSMCache.get(SSMCache.java:117)
    at org.springframework.cache.interceptor.AbstractCacheInvoker.doGet(AbstractCacheInvoker.java:68)
    at org.springframework.cache.interceptor.CacheAspectSupport.findInCaches(CacheAspectSupport.java:469)
    at org.springframework.cache.interceptor.CacheAspectSupport.findCachedItem(CacheAspectSupport.java:435)
    at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:336)
    at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:302)
    at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)

只要调用findOne(id)方法,我就会得到WrappedCacheException,代码就会失败。请帮帮忙。

EN

回答 1

Stack Overflow用户

发布于 2019-06-16 10:51:00

在4.0.0之前,从底层缓存/客户端层(例如IOExceptions等)抛出的异常被SsmCache对象吃掉。在4.0.0之后,默认情况下,这些都会抛给调用者。您可以通过将SsmCache bean上的"muteExceptions“标志设置为true来恢复到以前的行为。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53406810

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档