NutzCN Logo
问答 ehcache加入失败
发布于 2901天前 作者 qq_fbdf31f7 1637 次浏览 复制 上一个帖子 下一个帖子
标签:

我使用的是nutz1.58的jar包,以及ehcache.2.10.3的jar包
dao.js:

var ioc = {
	conf : {
		type : "org.nutz.ioc.impl.PropertiesProxy",
		fields: {
			paths : ["custom/"]
		}
	},	
	dataSource : {
		factory : "$conf#make",
        args : ["com.alibaba.druid.pool.DruidDataSource", "db."],
        type : "com.alibaba.druid.pool.DruidDataSource",
	},
	dao : {
		type : "org.nutz.dao.impl.NutDao",
		args : [{refer:"dataSource"}]
	}
};

ehcache.js:

var ioc = {
        cacheManager : {
            type : "net.sf.ehcache.CacheManager",
            factory : "net.sf.ehcache.CacheManager#getCacheManager",
            args : ["hq"] // 对应shiro.ini中指定的ehcache.xml中定义的name
        }
        /*      
        // 如果不需要shiro初始化的Ehcache, 使用下面的方式配置
        cacheManager : {
            type : "net.sf.ehcache.CacheManager",
            factory : "net.sf.ehcache.CacheManager#create"
        }
         */
};

ehcache.xml:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false"
    monitoring="autodetect" dynamicConfig="true" name="hq">
    <!-- <diskStore path="java.io.tmpdir/shiro-ehcache"/> -->
    <defaultCache
            maxElementsInMemory="10000"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="false"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"
            />
    <cache name="shiro-activeSessionCache"
           maxElementsInMemory="10000"
           overflowToDisk="true"
           eternal="true"
           timeToLiveSeconds="0"
           timeToIdleSeconds="0"
           diskPersistent="true"
           diskExpiryThreadIntervalSeconds="600"/>
</ehcache>

shiro.ini:

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

nutdao_realm = net.retror.nutzbook.shiro.realm.SimpleAuthorizingRealm

authc = org.nutz.integration.shiro.SimpleAuthenticationFilter
authc.loginUrl  = /user/login
logout.redirectUrl= /user/login


[urls]
/rs/*        = anon, noSessionCreation
/druid/*        = anon, noSessionCreation
/asserts/*        = anon, noSessionCreation
/user/logout = logout
/user/error  = anon
/user/profile/active/mail = anon
#/user/**     = authc

MainModule.java:

/**
 *
 * @author Retror
 */
@IocBy(args={"*js", "ioc/",
             "*anno", "net.retror.nutzbook",
             "*tx",
             "*async"})
@Modules(scanPackage=true)
@SetupBy(MainSetup.class)
@Ok("json")
@Fail("http:500")
@SessionBy(ShiroSessionProvider.class)
public class MainModule {


}

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	id="nutzbook" version="3.0">
	<filter>
		<filter-name>ShiroFilter</filter-name>
		<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>ShiroFilter</filter-name>
		<url-pattern>/*</url-pattern>
		<dispatcher>REQUEST</dispatcher>
		<dispatcher>FORWARD</dispatcher>
		<dispatcher>INCLUDE</dispatcher>
		<dispatcher>ERROR</dispatcher>
	</filter-mapping>
	<filter>
		<filter-name>DruidWebStatFilter</filter-name>
		<filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
		<init-param>
			<param-name>exclusions</param-name>
			<param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*,/rs/*</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>DruidWebStatFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<filter>
		<filter-name>nutz</filter-name>
		<filter-class>org.nutz.mvc.NutFilter</filter-class>
		<init-param>
			<param-name>modules</param-name>
			<param-value>net.retror.nutzbook.MainModule</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>nutz</filter-name>
		<url-pattern>/*</url-pattern>
		<dispatcher>REQUEST</dispatcher>
		<dispatcher>FORWARD</dispatcher>
		<dispatcher>INCLUDE</dispatcher>
	</filter-mapping>


	<listener>
		<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
	</listener>
</web-app>
	

启动项目的时候报错:

[ERROR] 10:46:44.081 org.apache.shiro.web.env.EnvironmentLoader.initEnvironment(EnvironmentLoader.java:146) - Shiro environment initialization failed
java.lang.IllegalArgumentException: Configuration error.  Specified object [nutzdao_realm] with property [cacheManager] without first defining that object's class.  Please first specify the class property first, e.g. myObject = fully_qualified_class_name and then define additional properties.
	at org.apache.shiro.config.ReflectionBuilder.applySingleProperty(ReflectionBuilder.java:361)
	at org.apache.shiro.config.ReflectionBuilder.applyProperty(ReflectionBuilder.java:325)
	at org.apache.shiro.config.ReflectionBuilder$AssignmentStatement.doExecute(ReflectionBuilder.java:955)
	at org.apache.shiro.config.ReflectionBuilder$Statement.execute(ReflectionBuilder.java:887)
	at org.apache.shiro.config.ReflectionBuilder$BeanConfigurationProcessor.execute(ReflectionBuilder.java:765)
	at org.apache.shiro.config.ReflectionBuilder.buildObjects(ReflectionBuilder.java:260)
	at org.apache.shiro.config.IniSecurityManagerFactory.buildInstances(IniSecurityManagerFactory.java:167)
	at org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:130)
	at org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:108)
	at org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:94)
	at org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:46)
	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.createWebSecurityManager(IniWebEnvironment.java:203)
	at org.apache.shiro.web.env.IniWebEnvironment.configure(IniWebEnvironment.java:99)
	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:4738)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:460)
	at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1586)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1460)
	at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:906)
	at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:344)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
24 回复

nutdao_realm nutzdao_realm

名字写错,且顺序写错

@wendal 顺序应该是什么呢?您说的是在那个shiro.ini配置里面的顺序吗?

@wendal 我换了顺序之后确实可以了,但是在启动项目的时候还是把上面的错,但是现在可以进入到页面里了,请问是我配置的问题还是可以不用忽视呢?

@qq_fbdf31f7 错误肯定不一样的,贴现在的报错信息

@wendal

[ERROR] 13:16:53.021 org.apache.shiro.web.env.EnvironmentLoader.initEnvironment(EnvironmentLoader.java:146) - Shiro environment initialization failed
java.lang.IllegalArgumentException: Configuration error.  Specified object [nutzdao_realm] with property [cacheManager] without first defining that object's class.  Please first specify the class property first, e.g. myObject = fully_qualified_class_name and then define additional properties.
	at org.apache.shiro.config.ReflectionBuilder.applySingleProperty(ReflectionBuilder.java:361)
	at org.apache.shiro.config.ReflectionBuilder.applyProperty(ReflectionBuilder.java:325)
	at org.apache.shiro.config.ReflectionBuilder$AssignmentStatement.doExecute(ReflectionBuilder.java:955)
	at org.apache.shiro.config.ReflectionBuilder$Statement.execute(ReflectionBuilder.java:887)
	at org.apache.shiro.config.ReflectionBuilder$BeanConfigurationProcessor.execute(ReflectionBuilder.java:765)
	at org.apache.shiro.config.ReflectionBuilder.buildObjects(ReflectionBuilder.java:260)
	at org.apache.shiro.config.IniSecurityManagerFactory.buildInstances(IniSecurityManagerFactory.java:167)

@qq_fbdf31f7 贴现在的shiro.ini

@wendal 只是报了这一个错,然后还报了一个其他项目没有启动的错误,我一并给你发一下吧。

[ERROR] 13:16:53.021 org.apache.shiro.web.env.EnvironmentLoader.initEnvironment(EnvironmentLoader.java:146) - Shiro environment initialization failed
java.lang.IllegalArgumentException: Configuration error.  Specified object [nutzdao_realm] with property [cacheManager] without first defining that object's class.  Please first specify the class property first, e.g. myObject = fully_qualified_class_name and then define additional properties.
	at org.apache.shiro.config.ReflectionBuilder.applySingleProperty(ReflectionBuilder.java:361)
	at org.apache.shiro.config.ReflectionBuilder.applyProperty(ReflectionBuilder.java:325)
	at org.apache.shiro.config.ReflectionBuilder$AssignmentStatement.doExecute(ReflectionBuilder.java:955)
	at org.apache.shiro.config.ReflectionBuilder$Statement.execute(ReflectionBuilder.java:887)
	at org.apache.shiro.config.ReflectionBuilder$BeanConfigurationProcessor.execute(ReflectionBuilder.java:765)
	at org.apache.shiro.config.ReflectionBuilder.buildObjects(ReflectionBuilder.java:260)
	at org.apache.shiro.config.IniSecurityManagerFactory.buildInstances(IniSecurityManagerFactory.java:167)
06-Dec-2016 13:16:53.071 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
06-Dec-2016 13:16:53.072 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/shiroWeb] startup failed due to previous errors
	at org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:130)
	at org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:108)
	at org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:94)
	at org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:46)
	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.createWebSecurityManager(IniWebEnvironment.java:203)
	at org.apache.shiro.web.env.IniWebEnvironment.configure(IniWebEnvironment.java:99)
	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:4738)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1780)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	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)

@wendal

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

nutdao_realm = net.retror.nutzbook.shiro.realm.SimpleAuthorizingRealm

authc = org.nutz.integration.shiro.SimpleAuthenticationFilter
authc.loginUrl  = /user/login
logout.redirectUrl= /user/login


[urls]
/rs/*        = anon, noSessionCreation
/druid/*        = anon, noSessionCreation
/asserts/*        = anon, noSessionCreation
/user/logout = logout
/user/error  = anon
/user/profile/active/mail = anon
#/user/**     = authc

@wendal

[main]
nutzdao_realm = net.retror.nutzbook.shiro.realm.SimpleAuthorizingRealm

cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
cacheManager.cacheManagerConfigFile=classpath:ehcache.xml
nutzdao_realm.cacheManager = $cacheManager

authc = org.nutz.integration.shiro.SimpleAuthenticationFilter
authc.loginUrl  = /user/login
logout.redirectUrl= /user/login


[urls]
/rs/*        = anon, noSessionCreation
/druid/*        = anon, noSessionCreation
/asserts/*        = anon, noSessionCreation
/user/logout = logout
/user/error  = anon
/user/profile/active/mail = anon
#/user/**     = authc

后面发的这个shiro.ini才是对的咯

@wendal 可是我用之后的这个,启动的时候还是会报上面的错误。。。不知道为何了。。。

[ERROR] 13:25:35.728 org.apache.shiro.web.env.EnvironmentLoader.initEnvironment(EnvironmentLoader.java:146) - Shiro environment initialization failed
java.lang.IllegalArgumentException: Configuration error.  Specified object [nutzdao_realm] with property [cacheManager] without first defining that object's class.  Please first specify the class property first, e.g. myObject = fully_qualified_class_name and then define additional properties.
	at org.apache.shiro.config.ReflectionBuilder.applySingleProperty(ReflectionBuilder.java:361)
	at org.apache.shiro.config.ReflectionBuilder.applyProperty(ReflectionBuilder.java:325)
	at org.apache.shiro.config.ReflectionBuilder$AssignmentStatement.doExecute(ReflectionBuilder.java:955)
	at org.apache.shiro.config.ReflectionBuilder$Statement.execute(ReflectionBuilder.java:887)
	at org.apache.shiro.config.ReflectionBuilder$BeanConfigurationProcessor.execute(ReflectionBuilder.java:765)
	at org.apache.shiro.config.ReflectionBuilder.buildObjects(ReflectionBuilder.java:260)
	at org.apache.shiro.config.IniSecurityManagerFactory.buildInstances(IniSecurityManagerFactory.java:167)
	at org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:130)
	at org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:108)
	at org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:94)
	at org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:46)
	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.createWebSecurityManager(IniWebEnvironment.java:203)
	at org.apache.shiro.web.env.IniWebEnvironment.configure(IniWebEnvironment.java:99)
	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:4738)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5181)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586)
	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1780)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	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)

@wendal 我重新编译了好几遍,但是还是在启动时会报这个错误。。。。真心不知道是为啥了。。。。是不是因为别的项目导致的?还是什么原因?

@qq_fbdf31f7 既然有怀疑的东西,就先排除掉

@wendal 兽总,我把其他项目里的ini文件也修改顺序之后就可以了,真的太感谢你拉~~谢谢拉~~~如果我想测试cachemanager的话可以先在哪个地方去测试呢?

@qq_fbdf31f7 找个service/module类注入就能用了

@wendal 还有为何我访问方法的时候会提示这个错误呢?这是什么情况呢?

2016-12-06 13:48:05,940 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:79) DEBUG - Remove object 'userModule' from [app] 
2016-12-06 13:48:05,942 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) WARN  - Error@/user/login :
org.nutz.ioc.IocException: [userModule, class:net.sf.ehcache.CacheManager] # none ioc bean match class=net.sf.ehcache.CacheManager
	at org.nutz.ioc.impl.NutIoc.getByType(NutIoc.java:382)
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:30)
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:209)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:235)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:116)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:196)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

iocby写错了吧,贴一下

@wendal

@IocBy(args={"*js", "dao.js",
             "*anno", "net.retror.bd",
             "*tx",
             "*async"})
@Modules(scanPackage=true)
@SetupBy(MainSetup.class)
@Ok("json")
@Fail("http:500")
@SessionBy(ShiroSessionProvider.class)
public class MainModule {


}

@qq_fbdf31f7 建个ioc文件夹,把dao.js,ehcache.js都放进去,然后iocby改成

"*js","ioc/"

@wendal 最好是这样是吗,兽总?我是直接放到默认包下面了,那就是说,一般有一个js的话想加入到容器当中,肯定得包那个包含所有js的包通过IOCBY加入到容器当中是吗?

@qq_fbdf31f7 放文件夹好

@wendal 嗯嗯,我修改之后可以了,我去试试看那个cache能不能注入进来~~

@wendal
代码:

 @POST
    @At
    @Ok("jsp:index")
    public boolean login(HttpServletRequest resq,HttpSession session){
        System.out.println("1111111111");
        System.out.println(cacheManager);
        System.out.println("1111111111");
        String userCode = resq.getParameter("userCodeInput");
        String password = resq.getParameter("passwordInput");
        if (Strings.isBlank(userCode) || Strings.isBlank(password)) {
            return false;
        }
        User user = userOpService.findUserByCode(userCode);
        if (user == null) {
            return false;
        }
//        String tmp = new Sha256Hash(password, user.getSalt()).toHex();
//        if (!tmp.equals(user.getPassword())) {
//            return false;
//        }  log.debug("password is wrong");
//            return false;
//        }
        //添加token为后来的权限做验证
        SecurityUtils.getSubject().login(new SimpleShiroToken(user.getUserId()));
        //或者传递用户名、密码
//        UsernamePasswordToken userToken = new UsernamePasswordToken(user.getName(),user.getPassword().toCharArray(),false);
//        SecurityUtils.getSubject().login(userToken);
        session.setAttribute("me", user);
        resq.setAttribute("name", user.getUserName());
        resq.setAttribute("code", user.getUserCode());
        return true;
        
    }

控制台输出:

1111111111
hq
1111111111

太谢谢兽总了,学到很多~~真的谢谢拉~~~~

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