NutzCN Logo
问答 nutzbook Role 表加载数据异常
发布于 3286天前 作者 Rekoe 2989 次浏览 复制 上一个帖子 下一个帖子
标签: nutzbook

定义方法

public List<Role> roleList() {
		Object obj = dao.query(Role.class, null);
		System.out.println(obj);
		return new ArrayList<Role>();
	}
调用此方法会有异常
	DEBUG - SELECT * FROM t_role 
[/*net.wendal.nutzbook.bean.Role@25061d99*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"}]
2015-11-24 16:09:49,919 org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:193) DEBUG - SELECT * FROM t_permission 
2015-11-24 16:09:49,942 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:123) ERROR - Error happend during start serivce!
org.nutz.castor.FailToCastObjectException: Fail to cast from <net.wendal.nutzbook.bean.Role> to <java.lang.Integer> for {/*net.wendal.nutzbook.bean.Role@85ec775*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"}} because:
BorningException:Fail to born 'java.lang.Integer'
 by args: [
  @(/*net.wendal.nutzbook.bean.Role@85ec775*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"})] becasue:
java.lang.NumberFormatException: For input string: "/*net.wendal.nutzbook.bean.Role@85ec775*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"}"
	at org.nutz.castor.Castors.cast(Castors.java:258)
	at org.nutz.castor.Castors.castTo(Castors.java:320)
	at org.nutz.castor.castor.Collection2Object.cast(Collection2Object.java:17)
	at org.nutz.castor.castor.Collection2Object.cast(Collection2Object.java:9)
	at org.nutz.castor.Castors.cast(Castors.java:252)
	at org.nutz.castor.Castors.castTo(Castors.java:320)
	at org.nutz.dao.impl.sql.NutStatement.getObject(NutStatement.java:117)
	at org.nutz.dao.impl.sql.NutStatement.getInt(NutStatement.java:121)
	at org.nutz.dao.impl.NutDao.each(NutDao.java:469)
	at org.nutz.dao.impl.NutDao.each(NutDao.java:473)
	at net.wendal.nutzbook.service.AuthorityServiceImpl.initFormPackage(AuthorityServiceImpl.java:69)
	at net.wendal.nutzbook.MainSetup.init(MainSetup.java:147)
	at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:270)
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:119)
	at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
	at org.nutz.mvc.NutFilter.init(NutFilter.java:77)
	at net.wendal.nutzbook.mvc.NutzBookNutFilter.init(NutzBookNutFilter.java:24)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
	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)
Caused by: java.lang.NumberFormatException: For input string: "/*net.wendal.nutzbook.bean.Role@85ec775*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"}"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:569)
	at java.lang.Integer.<init>(Integer.java:867)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
	at org.nutz.lang.born.ConstructorCastingBorning.born(ConstructorCastingBorning.java:21)
	at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
	at org.nutz.lang.Mirror.born(Mirror.java:967)
	at org.nutz.castor.castor.Object2Object.cast(Object2Object.java:12)
	at org.nutz.castor.Castors.cast(Castors.java:252)
	... 29 more
2015-11-24 16:09:49,942 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:125) ERROR - try to depose ioc
2015-11-24 16:09:49,942 org.quartz.core.QuartzScheduler.shutdown(QuartzScheduler.java:694) INFO  - Scheduler NutzbookScheduler_$_NON_CLUSTERED shutting down.
2015-11-24 16:09:49,942 org.quartz.core.QuartzScheduler.standby(QuartzScheduler.java:613) INFO  - Scheduler NutzbookScheduler_$_NON_CLUSTERED paused.
2015-11-24 16:09:49,942 org.quartz.core.QuartzScheduler.shutdown(QuartzScheduler.java:771) INFO  - Scheduler NutzbookScheduler_$_NON_CLUSTERED shutdown complete.
2015-11-24 16:09:50,349 org.zbus.net.core.Dispatcher.stop(Dispatcher.java:138) INFO  - Dispatcher(SelectorCount=1) stopped
2015-11-24 16:09:50,380 org.zbus.net.core.Dispatcher.stop(Dispatcher.java:138) INFO  - Dispatcher(SelectorCount=1) stopped
2015-11-24 16:09:50,380 com.alibaba.druid.pool.DruidDataSource.close(DruidDataSource.java:1385) INFO  - {dataSource-1} closed
十一月 24, 2015 4:09:50 下午 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter nutz
org.nutz.mvc.LoadingException: org.nutz.castor.FailToCastObjectException: Fail to cast from <net.wendal.nutzbook.bean.Role> to <java.lang.Integer> for {/*net.wendal.nutzbook.bean.Role@85ec775*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"}} because:
BorningException:Fail to born 'java.lang.Integer'
 by args: [
  @(/*net.wendal.nutzbook.bean.Role@85ec775*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"})] becasue:
java.lang.NumberFormatException: For input string: "/*net.wendal.nutzbook.bean.Role@85ec775*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"}"
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
	at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:17)
	at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
	at org.nutz.lang.Mirror.born(Mirror.java:967)
	at org.nutz.lang.Lang.wrapThrow(Lang.java:164)
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:133)
	at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
	at org.nutz.mvc.NutFilter.init(NutFilter.java:77)
	at net.wendal.nutzbook.mvc.NutzBookNutFilter.init(NutzBookNutFilter.java:24)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
	at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
	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)
Caused by: org.nutz.castor.FailToCastObjectException: Fail to cast from <net.wendal.nutzbook.bean.Role> to <java.lang.Integer> for {/*net.wendal.nutzbook.bean.Role@85ec775*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"}} because:
BorningException:Fail to born 'java.lang.Integer'
 by args: [
  @(/*net.wendal.nutzbook.bean.Role@85ec775*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"})] becasue:
java.lang.NumberFormatException: For input string: "/*net.wendal.nutzbook.bean.Role@85ec775*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"}"
	at org.nutz.castor.Castors.cast(Castors.java:258)
	at org.nutz.castor.Castors.castTo(Castors.java:320)
	at org.nutz.castor.castor.Collection2Object.cast(Collection2Object.java:17)
	at org.nutz.castor.castor.Collection2Object.cast(Collection2Object.java:9)
	at org.nutz.castor.Castors.cast(Castors.java:252)
	at org.nutz.castor.Castors.castTo(Castors.java:320)
	at org.nutz.dao.impl.sql.NutStatement.getObject(NutStatement.java:117)
	at org.nutz.dao.impl.sql.NutStatement.getInt(NutStatement.java:121)
	at org.nutz.dao.impl.NutDao.each(NutDao.java:469)
	at org.nutz.dao.impl.NutDao.each(NutDao.java:473)
	at net.wendal.nutzbook.service.AuthorityServiceImpl.initFormPackage(AuthorityServiceImpl.java:69)
	at net.wendal.nutzbook.MainSetup.init(MainSetup.java:147)
	at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:270)
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:119)
	... 16 more
Caused by: java.lang.NumberFormatException: For input string: "/*net.wendal.nutzbook.bean.Role@85ec775*/{"id":1,"name":"admin","createTime":"2015-11-19 10:06:24","updateTime":"2015-11-19 10:06:24"}"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:569)
	at java.lang.Integer.<init>(Integer.java:867)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
	at org.nutz.lang.born.ConstructorCastingBorning.born(ConstructorCastingBorning.java:21)
	at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
	at org.nutz.lang.Mirror.born(Mirror.java:967)
	at org.nutz.castor.castor.Object2Object.cast(Object2Object.java:12)
	at org.nutz.castor.Castors.cast(Castors.java:252)
	... 29 more
十一月 24, 2015 4:09:50 下午 org.apache.catalina.core.StandardContext startInternal
严重: Error filterStart
10 回复

刚刚试了一下, 在MainSetup里面查2次,报错, 我查查才行

@wendal
嗯 好

@wendal
单独写了一个RoleService
调用这个方法的时候报这个错误

2015-11-24 16:24:12,240 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) WARN  - Error@/admin/user/edit :
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.List
	at org.nutz.dao.impl.sql.NutStatement.getList(NutStatement.java:113)
	at org.nutz.dao.impl.NutDao.query(NutDao.java:452)
	at org.nutz.dao.impl.NutDao.query(NutDao.java:456)
	at net.wendal.nutzbook.service.RoleService.roleList(RoleService.java:23)
	at net.wendal.nutzbook.module.admin.AdminUserModule.edit(AdminUserModule.java:57)
	at net.wendal.nutzbook.module.admin.AdminUserModule$$FASTCLASS._invoke(AdminUserModule.java:1)
	at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
	at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:40)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.integration.shiro.NutShiroProcessor.process(NutShiroProcessor.java:51)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:113)
	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.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at net.wendal.nutzbook.mvc.LogTimeProcessor.process(LogTimeProcessor.java:19)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:40)
	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:183)
	at net.wendal.nutzbook.mvc.NutzBookNutFilter.doFilter(NutzBookNutFilter.java:42)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	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:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	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.each跟dao.query的sql一致,但返回值不一样导致的

问题应该在daocache上
我把t_role表的缓存取消就没有这个错误了

那检查完清理下那个表的缓存
@wendal

daocache 可以单独控制清理下某个表的缓存么
@wendal

还是你在daochche上处理下?

daocache 1.b.53.r2 等更新

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