NutzCN Logo
问答 发现一个bug,希望大神可以帮我解决
发布于 2593天前 作者 qq_1d84c364 2275 次浏览 复制 上一个帖子 下一个帖子
标签:

我的sql使用了beetl模板,sql语句如下:

/* getMaterielListByCompanyId */
SELECT a.`id`,a.`no`, a.`name`,a.`type`  FROM tmateriel a WHERE a.companyId = @companyId
<% if (has("searchText")) {%>
	and concat(a.`no`,a.`name`,a.`type`) like @searchText
<% } %>
order by a.`no`

log4j在debug模式下正常,一旦切换到info模式下,报错,日志如下:

[WARN ] 16:36:46.053 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) - Error@/standard/doLoadStandard :
org.nutz.dao.DaoException: java.lang.ArrayIndexOutOfBoundsException: 1
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
	at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:236)
	at org.nutz.dao.impl.NutDao.execute(NutDao.java:1008)
	at com.easysoft.service.StandardService.getStandardList(StandardService.java:116)
	at com.easysoft.controller.StandardController.doLoadStandard(StandardController.java:129)
	at com.easysoft.controller.StandardController$FM$doLoadStandard$50c48f684fbc77ff250702399cde55c9.invoke(StandardController.java)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
	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:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.easysoft.MyEncodeProcessor.process(MyEncodeProcessor.java:11)
	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:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	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:141)
	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:528)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
	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)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:269)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:53)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
	... 44 more

我调试过,NutDaoExecutor中代码

for (int i = 0; i < paramMatrix[0].length; i++) {
                    adaptors[i].set((PreparedStatement) stat,
                            paramMatrix[0][i], i + 1);
                }

adaptors长度为1
info模式下:
companyId为32,searchText为null时,paramMatrix[0]的长度为2,直接数组越界
debug模式下:
companyId为32,searchText为null时,paramMatrix[0]的长度为1,万事ok
找了一个星期了,没有头绪

15 回复

paramMatrix[0]的长度获取把<%%>之间的sql也拿出来计算了,其实应该先判断参数,决定sql的拼接情况后再计算,无奈无不会改,我想知道如何避免

把代码再精简一下, 把问题最小化, 感觉是获取参数矩阵的时候有问题

我用过最精简的代码试过了,每次都报错

用了beetel模板,callback为record,debug模式就出错

把你的最精简代码发一下

好 我整理一下

我明天发给你

感觉是render调用的时机导致的问题

可以插附件吗?你私个可以接收附件的邮箱给我,我的邮箱694931357@qq.com

我提交个修改,你待会看一下

好的,发个链接我看看

请问你这个修改我本地该如何对jar包进行修改啊?

经测试,没问题了

就改了NutSqlTpl类,你可以取最新的快照jar

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