NutzCN Logo
问答 启用-Redis作为shiro二级缓存时启用这里报错
发布于 2767天前 作者 qq_64f81159 2857 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

shiro配置文件如下

[main]
# cacheManager
#cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
#cacheManager.cacheManagerConfigFile = classpath:ehcache.xml

-------------Redis作为shiro二级缓存时启用这里---------
jedisAgent = org.nutz.integration.jedis.JedisAgent
cacheManager_ehcache = org.apache.shiro.cache.ehcache.EhCacheManager
cacheManager_ehcache.cacheManagerConfigFile=classpath:ehcache.xml
cacheManager_redis = org.nutz.plugins.cache.impl.redis.RedisCacheManager
cacheManager_redis.mode=kv
cacheManager_redis.debug=true
cacheManager = org.nutz.plugins.cache.impl.lcache.LCacheManager
cacheManager.jedisAgent = $jedisAgent
cacheManager.level1 = $cacheManager_ehcache
cacheManager.level2 = $cacheManager_redis
-------------Redis作为shiro二级缓存时启用这里---------

# Session
sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager
sessionManager.sessionValidationSchedulerEnabled = false

# Session Cache
sessionDAO = org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO
sessionDAO.cacheManager = $cacheManager
sessionDAO.activeSessionsCacheName = shiro-activeSessionCache
sessionManager.sessionDAO = $sessionDAO
securityManager.sessionManager = $sessionManager

# Cookie
sessionIdCookie = org.apache.shiro.web.servlet.SimpleCookie
sessionIdCookie.name = sid
#sessionIdCookie.domain=wizzer.cn
#sessionIdCookie.path=
sessionIdCookie.maxAge = 946080000
sessionIdCookie.httpOnly = true
sessionManager.sessionIdCookie = $sessionIdCookie
sessionManager.sessionIdCookieEnabled = true
sessionManager.globalSessionTimeout = 3600000

#bak...
#sessionManager=org.apache.shiro.web.session.mgt.DefaultWebSessionManager
#sessionListener1 = cn.wizzer.common.shiro.listener.MySessionListener
#sessionManager.sessionListeners = $sessionListener1
#sessionManager.globalSessionTimeout=50000
#securityManager.sessionManager=$sessionManager

rememberMeCookie = org.apache.shiro.web.servlet.SimpleCookie
rememberMeCookie.name = remember
rememberMeCookie.maxAge = 604800
rememberMeCookie.httpOnly = true
rememberMeManager = org.apache.shiro.web.mgt.CookieRememberMeManager
rememberMeManager.cookie = $rememberMeCookie

sha256Matcher = org.apache.shiro.authc.credential.Sha256CredentialsMatcher
sha256Matcher.storedCredentialsHexEncoded = false
sha256Matcher.hashIterations = 1024
sha256Matcher.hashSalted = true

shiroDbRealm = com.kanq.common.shiro.realm.NutDaoRealm
shiroDbRealm.credentialsMatcher = $sha256Matcher

securityManager.realms = $shiroDbRealm
authcStrategy = com.kanq.common.shiro.authc.pam.AnySuccessfulStrategy
securityManager.authenticator.authenticationStrategy = $authcStrategy
securityManager.cacheManager = $cacheManager
securityManager.rememberMeManager = $rememberMeManager

authc = com.kanq.common.shiro.filter.SimpleAuthenticationFilter
authc.loginUrl = /platform/login
logout.redirectUrl = /platform/login

[urls]
/platform/doLogin = anon
/assets/** = anon
/** = anon
/platform/** = authc

错误是

五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version:        Apache Tomcat/7.0.57
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built:          Nov 3 2014 08:39:16 UTC
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number:         7.0.57.0
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name:               Windows 8.1
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version:            6.3
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture:          amd64
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JAVA_HOME:             E:\Java\jdk1.7.0_80\jre
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version:           1.7.0_80-b15
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor:            Oracle Corporation
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE:         D:/tomcat-7.0
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME:         D:/tomcat-7.0
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:59408
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:/tomcat-7.0
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:/tomcat-7.0
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=D:/tomcat-7.0/common/endorsed
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.io.tmpdir=D:/tomcat-7.0/temp
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.library.path=E:/Java/jdk1.7.0_80/bin;D:/tomcat-7.0/bin
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dsun.io.useCanonCaches=false
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Xms256m
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Xmx512m
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -XX:MaxNewSize=256m
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -XX:MaxPermSize=256m
五月 26, 2017 5:57:06 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
五月 26, 2017 5:57:06 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library 1.1.32 using APR version 1.5.1.
五月 26, 2017 5:57:06 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
五月 26, 2017 5:57:07 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized (OpenSSL 1.0.1j 15 Oct 2014)
五月 26, 2017 5:57:07 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-apr-8844"]
五月 26, 2017 5:57:07 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
五月 26, 2017 5:57:07 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1188 ms
五月 26, 2017 5:57:07 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
五月 26, 2017 5:57:07 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.57
五月 26, 2017 5:57:07 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\tomcat-7.0\webapps\cms
五月 26, 2017 5:57:07 下午 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(D:\tomcat-7.0\webapps\cms\WEB-INF\lib\servlet-api-2.3.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
五月 26, 2017 5:57:07 下午 org.apache.catalina.deploy.WebXml setVersion
警告: Unknown version string [3.1]. Default version will be used.
五月 26, 2017 5:57:10 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Shiro environment
2017-05-26 17:57:10,377 org.apache.shiro.io.ResourceUtils.loadFromClassPath(ResourceUtils.java:159) DEBUG - Opening resource from class path [shiro.ini]
2017-05-26 17:57:10,386 org.apache.shiro.config.Ini.load(Ini.java:342) DEBUG - Parsing [main]
2017-05-26 17:57:10,390 org.apache.shiro.web.env.EnvironmentLoader.initEnvironment(EnvironmentLoader.java:146) ERROR - Shiro environment initialization failed
java.lang.IllegalArgumentException: Line argument must contain a key and a value.  Only one string token was found.
	at org.apache.shiro.config.Ini$Section.splitKeyValue(Ini.java:542)
	at org.apache.shiro.config.Ini$Section.toMapProps(Ini.java:567)
	at org.apache.shiro.config.Ini$Section.<init>(Ini.java:464)
	at org.apache.shiro.config.Ini$Section.<init>(Ini.java:445)
	at org.apache.shiro.config.Ini.addSection(Ini.java:302)
	at org.apache.shiro.config.Ini.load(Ini.java:334)
	at org.apache.shiro.config.Ini.load(Ini.java:287)
	at org.apache.shiro.config.Ini.load(Ini.java:275)
	at org.apache.shiro.web.env.IniWebEnvironment.convertPathToIni(IniWebEnvironment.java:265)
	at org.apache.shiro.web.env.IniWebEnvironment.createIni(IniWebEnvironment.java:163)
	at org.apache.shiro.web.env.IniWebEnvironment.getDefaultIni(IniWebEnvironment.java:134)
	at org.apache.shiro.web.env.IniWebEnvironment.init(IniWebEnvironment.java:82)
	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:4994)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1245)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1895)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
五月 26, 2017 5:57:10 下午 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: Line argument must contain a key and a value.  Only one string token was found.
	at org.apache.shiro.config.Ini$Section.splitKeyValue(Ini.java:542)
	at org.apache.shiro.config.Ini$Section.toMapProps(Ini.java:567)
	at org.apache.shiro.config.Ini$Section.<init>(Ini.java:464)
	at org.apache.shiro.config.Ini$Section.<init>(Ini.java:445)
	at org.apache.shiro.config.Ini.addSection(Ini.java:302)
	at org.apache.shiro.config.Ini.load(Ini.java:334)
	at org.apache.shiro.config.Ini.load(Ini.java:287)
	at org.apache.shiro.config.Ini.load(Ini.java:275)
	at org.apache.shiro.web.env.IniWebEnvironment.convertPathToIni(IniWebEnvironment.java:265)
	at org.apache.shiro.web.env.IniWebEnvironment.createIni(IniWebEnvironment.java:163)
	at org.apache.shiro.web.env.IniWebEnvironment.getDefaultIni(IniWebEnvironment.java:134)
	at org.apache.shiro.web.env.IniWebEnvironment.init(IniWebEnvironment.java:82)
	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:4994)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1245)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1895)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
五月 26, 2017 5:57:10 下午 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart
五月 26, 2017 5:57:10 下午 org.apache.catalina.util.SessionIdGenerator createSecureRandom
信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [106] milliseconds.
五月 26, 2017 5:57:10 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/cms] startup failed due to previous errors
五月 26, 2017 5:57:10 下午 org.apache.catalina.core.ApplicationContext log
信息: Cleaning up Shiro Environment
五月 26, 2017 5:57:10 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\tomcat-7.0\webapps\cms has finished in 2,827 ms
五月 26, 2017 5:57:10 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\tomcat-7.0\webapps\docs
五月 26, 2017 5:57:10 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\tomcat-7.0\webapps\docs has finished in 60 ms
五月 26, 2017 5:57:10 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\tomcat-7.0\webapps\examples
五月 26, 2017 5:57:10 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
五月 26, 2017 5:57:10 下午 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
五月 26, 2017 5:57:10 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@59bd80fc')
五月 26, 2017 5:57:10 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\tomcat-7.0\webapps\examples has finished in 278 ms
五月 26, 2017 5:57:10 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\tomcat-7.0\webapps\host-manager
五月 26, 2017 5:57:10 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\tomcat-7.0\webapps\host-manager has finished in 45 ms
五月 26, 2017 5:57:10 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\tomcat-7.0\webapps\manager
五月 26, 2017 5:57:10 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\tomcat-7.0\webapps\manager has finished in 42 ms
五月 26, 2017 5:57:10 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\tomcat-7.0\webapps\ROOT
五月 26, 2017 5:57:10 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\tomcat-7.0\webapps\ROOT has finished in 38 ms
五月 26, 2017 5:57:10 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-apr-8844"]
五月 26, 2017 5:57:11 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-apr-8009"]
五月 26, 2017 5:57:11 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 3362 ms

不启用redis二级缓存没有问题。

13 回复

这句话要加井号注释掉

-------------Redis作为shiro二级缓存时启用这里---------

给我发一个吐血的表情……

开启了缓存和没有开启缓存除了在关闭页面重新开启页面不用输入用户名密码以外,还能看到哪些区别?

然后如果要分布式部署的话,可以自动session共享,不需要配置什么或者加其他代码?

比如对于一些打开过的页面,再次加载的时候是否会进行缓存,不用读取数据库?还是需要自己写代码放到redis上面?

如果要部署到几台服务器上,需要增加额外的配置 还是直接用nginx进行反向代理下就可以了,就可以session共享了?

你这里配的是session的,跟数据库没关系

真要上分布式的话,数据库缓存去掉吧

我这是两个问题啊,一个是要几台服务器部署nutzwk的话不增加代码或者修改tomcat配置就能session共享吗,第二个问题是Redis作为shiro二级缓存时启用这里,缓存了什么东西。

第一个问题,是

第二个问题,session

添加回复
请先登陆
回到顶部