阿帕奇四郎的Ehcache初始化例外:另一不愿透露姓名的CacheManager已存在于同一个VM [英] Apache Shiro EhCache initialization exception: Another unnamed CacheManager already exists in the same VM

查看:1951
本文介绍了阿帕奇四郎的Ehcache初始化例外:另一不愿透露姓名的CacheManager已存在于同一个VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得的Ehcache配置处理授权缓存在我的Apache四郎启用Web服务。目前,我得到了以下异常:

I am trying to get EhCache configured to handle authorization caching in my Apache Shiro enabled web service. Currently I am getting the following exception:

org.apache.shiro.cache.CacheException:net.sf.ehcache.CacheException:另一不愿透露姓名的CacheManager已经存在于同一个VM。在配置每个CacheManager的请提供唯一的名称或做下列操作之一:结果
  1.使用CacheManager.create()的一个静态工厂方法重复使用相同的CacheManager具有相同的名称或在必要时结果创建一个
  2.关闭创建新的同名之前较早的CacheManager。

org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.

我shiro.ini样子:结果
    [主]结果
    ...结果
    的CacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
    cacheManager.cacheManagerConfigFile =类路径:ehcache.xml中结果
    securityManager.cacheManager = $ CacheManager的

My shiro.ini looks like:
[main]
...
cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager cacheManager.cacheManagerConfigFile = classpath:ehcache.xml
securityManager.cacheManager = $cacheManager

从这个计算器后,它看起来像使用Spring的人通过强制CacheManager的是一个单解决此问题已经得到了:<一href=\"http://stackoverflow.com/questions/10013288/another-unnamed-cachemanager-already-exists-in-the-same-vm-ehcache-2-5\">Another不愿透露姓名的CacheManager已经存在于同一VM(2.5的EHCache)。

From this StackOverflow post it looks like people using Spring have gotten around this issue by forcing the CacheManager to be a singleton: Another unnamed CacheManager already exists in the same VM (ehCache 2.5).

是否有人知道不使用Spring的初始化变通的(我的dropwizard框架内工作,但是没有必要在Spring拉)?有没有从shiro.ini执行单配置的一些方式?

Is anybody aware of work-arounds not using Spring initialization (I'm working within the dropwizard framework and have no need to pull in Spring)? Is there some manner of enforcing singleton configuration from the shiro.ini?

感谢你在前进!

推荐答案

创建一个扩展EhCacheManager自定义类,并设置您的CacheManager在构造函数中。这(net.sf.ehcache.CacheManager.create()),您可以重用现有的CacheManager。

Create a custom class that extends EhCacheManager and set your cacheManager in the constructor. This (net.sf.ehcache.CacheManager.create()) allows you to reuse an already existing cachemanager.

package lekkie.omotayo

public class MyShiroCacheManager extends EhCacheManager
{

    public CacheManager()
    {
        setCacheManager(net.sf.ehcache.CacheManager.create());
    }
}

然后,你可以这样做:

Then you can do this:

cacheManager = lekkie.omotayo.MyShiroCacheManager
cacheManager.cacheManagerConfigFile = classpath:ehcache.xml
securityManager.cacheManager = $cacheManager

这篇关于阿帕奇四郎的Ehcache初始化例外:另一不愿透露姓名的CacheManager已存在于同一个VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆