按照nutzbook中的讲解,在做17.集成Ehcache及DaoCache 这一部分时,老是报异常:
能指点下如何配置吗?
shiro.ini:
[main]
sha256Matcher = org.apache.shiro.authc.credential.Sha256CredentialsMatcher
nutzdao_realm = com.zhangwei.test.nutzbook.shiro.realm.NutDaoRealm
nutzdao_realm.credentialsMatcher = $sha256Matcher
authc = org.nutz.integration.shiro.CaptchaFormAuthenticationFilter
authc.loginUrl = /user2/user3/login
logout.redirectUrl= /user2/user3/login
[urls]
/rs/* = anon
/user2/user3/logout = logout
/user2/user3/error = anon
/user2/user3/profile/active/mail = anon
/user2/user3/** = authc
cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
cacheManager.cacheManagerConfigFile=classpath:ehcache.xml
nutzdao_realm.cacheManager = $cacheManager
#如果需要缓存shiro的Session,可以加入这些配置(不推荐)
#sessionDAO = org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO
#sessionManager.sessionDAO = $sessionDAO
#securityManager.sessionManager = $sessionManager
#
#securityManager.cacheManager = $cacheManager
ehcahe.js:
var ioc = {
cacheManager : {
type : "net.sf.ehcache.CacheManager",
factory : "net.sf.ehcache.CacheManager#getCacheManager",
args : ["nutz-book"] // 对应shiro.ini中指定的ehcache.xml中定义的name
}
/*
// 如果不需要shiro初始化的Ehcache, 使用下面的方式配置
cacheManager : {
type : "net.sf.ehcache.CacheManager",
factory : "net.sf.ehcache.CacheManager#create"
}
*/
};
十一月 18, 2016 5:13:59 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.apache.shiro.web.env.EnvironmentLoaderListener
java.lang.IllegalArgumentException: There is no filter with name 'org.apache.shiro.cache.ehcache.EhCacheManager' to apply to chain [cacheManager] in the pool of available Filters. Ensure a filter with that name/path has first been registered with the addFilter method(s).
at org.apache.shiro.web.filter.mgt.DefaultFilterChainManager.addToChain(DefaultFilterChainManager.java:265)
at org.apache.shiro.web.filter.mgt.DefaultFilterChainManager.createChain(DefaultFilterChainManager.java:148)
at org.apache.shiro.web.config.IniFilterChainResolverFactory.createChains(IniFilterChainResolverFactory.java:192)
at org.apache.shiro.web.config.IniFilterChainResolverFactory.buildChains(IniFilterChainResolverFactory.java:127)
at org.apache.shiro.web.config.IniFilterChainResolverFactory.createInstance(IniFilterChainResolverFactory.java:80)
at org.apache.shiro.web.config.IniFilterChainResolverFactory.createInstance(IniFilterChainResolverFactory.java:43)
at org.apache.shiro.config.IniFactorySupport.createInstance(IniFactorySupport.java:123)
at org.apache.shiro.util.AbstractFactory.getInstance(AbstractFactory.java:47)
at org.apache.shiro.web.env.IniWebEnvironment.createFilterChainResolver(IniWebEnvironment.java:187)
at org.apache.shiro.web.env.IniWebEnvironment.configure(IniWebEnvironment.java:102)
at org.apache.shiro.web.env.IniWebEnvironment.init(IniWebEnvironment.java:92)
at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:45)
at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:40)
at org.apache.shiro.web.env.EnvironmentLoader.createEnvironment(EnvironmentLoader.java:221)
at org.apache.shiro.web.env.EnvironmentLoader.initEnvironment(EnvironmentLoader.java:133)
at org.apache.shiro.web.env.EnvironmentLoaderListener.contextInitialized(EnvironmentLoaderListener.java:58)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4853)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
dao.js:
var ioc = {
conf : {
type : "org.nutz.ioc.impl.PropertiesProxy",
fields : {
paths : ["custom/"]
}
},
dataSource : {
type : "com.alibaba.druid.pool.DruidDataSource",
events : {
create : "init",
depose : 'close'
},
fields : {
url : {java:"$conf.get('db.url')"},
username : {java:"$conf.get('db.username')"},
password : {java:"$conf.get('db.password')"},
testWhileIdle : true,
validationQuery : {java:"$conf.get('db.validationQuery')"},
maxActive : {java:"$conf.get('db.maxActive')"},
filters : "wall,mergeStat",
connectionProperties : "druid.stat.slowSqlMillis=2000"
}
},
dao : {
type : "org.nutz.dao.impl.NutDao",
args : [{refer:"dataSource"}]
}
};
nutzbook-mvc-chain.js:
var chain={
"default" : {
"ps" : [
"com.zhangwei.test.nutzbook.mvc.LogTimeProcessor",
"org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor",
"org.nutz.mvc.impl.processor.EncodingProcessor",
"org.nutz.mvc.impl.processor.ModuleProcessor",
"org.nutz.integration.shiro.NutShiroProcessor",
"org.nutz.mvc.impl.processor.ActionFiltersProcessor",
"org.nutz.mvc.impl.processor.AdaptorProcessor",
"org.nutz.mvc.impl.processor.MethodInvokeProcessor",
"org.nutz.mvc.impl.processor.ViewProcessor"
],
"error" : 'org.nutz.mvc.impl.processor.FailProcessor'
}
};