NutzCN Logo
问答 适配器问题,升到1.63后出现问题,升级前正常
发布于 2571天前 作者 shuxinyun 1460 次浏览 复制 上一个帖子 下一个帖子
标签:

入口配置:

@AdaptBy(type = JsonAdaptor.class)
    @At
    @Ok("json:{ignoreNull:false}")
    @POST
    public Object flow_input(@Param("data") Doc_flow[] flows, HttpServletRequest req) {
        try {
            List<Doc_flow> list=new ArrayList<>();
            for(Doc_flow flow:flows){
                list.add(flow);
            }
            return Result.success("ok",flowEngine.flowInput(list));
        } catch (Exception e) {
            Utils.print("----------预发数据提交(flow_input)错误----------");
            Utils.print("data="+Json.toJson(flows));
            Utils.print(e.getMessage());
            Utils.print("----------预发数据提交(flow_input)错误----------");
            return Result.error(e.getMessage());
        }
    }

接口访问:

var data=[{"documentId":"","codebar":"GB0626-2005^undefined0000^外交部^^12^^12^非密^无^20171208^^外交部亚洲司^20171208^^|","traceCode":"00018640000170070002","handleType":"4","rfid":"-58a89394:16034b333d8:-7e98","title":"12","docNo":"12","shareNo":"","bn":"00006","fromNodeId":"40280c9c5aff2ba8015aff7ed2f90015","toNodeId":"a4103ab966ae4a5c82bd87e197c6a5e6","status":"1","secret":"非密","urgent":"1","abnormity":"0","receiveEmployeeId":"0","sendEmployeeId":"64fa4ef015cc89bfd737fcf","type":"0","dropType":"0"}];
                    $.post(api+"doc/flow_input?appId="+appid+"&token="+token, {data:JSON.stringify(data)}, function (result) {
                        if(result.code==0) {
                            document.write("<br>demo=测试数据:"+result.data);
                            console.log('demo=');
                            console.log(result.data);
                        }
                        else {
                            alert(result.msg);
                        }
                    }, "json");

错误日志:

[DEBUG] 2017-12-08 21:28:56,299 cn.wizzer.app.web.commons.processor.LogTimeProcessor.process(LogTimeProcessor.java:26) - [POST]URI=/open/api/doc/flow_input 1319ms
[WARN ] 2017-12-08 21:28:56,302 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) - Error@/open/api/doc/flow_input :
org.nutz.castor.FailToCastObjectException: Fail to cast from <java.lang.String> to <cn.wizzer.app.doc.modules.models.Doc_flow> for {[{"documentId":"","codebar":"GB0626-2005^undefined0000^外交部^^12^^12^非密^无^20171208^^外交部亚洲司^20171208^^|","traceCode":"00018640000170070002","handleType":"4","rfid":"-58a89394:16034b333d8:-7e98","title":"12","docNo":"12","shareNo":"","bn":"00006","fromNodeId":"40280c9c5aff2ba8015aff7ed2f90015","toNodeId":"a4103ab966ae4a5c82bd87e197c6a5e6","status":"1","secret":"非密","urgent":"1","abnormity":"0","receiveEmployeeId":"0","sendEmployeeId":"64fa4ef015cc89bfd737fcf","type":"0","dropType":"0"}]}
	at org.nutz.castor.Castors.cast(Castors.java:262)
	at org.nutz.castor.Castors.castTo(Castors.java:316)
	at org.nutz.mvc.adaptor.injector.ArrayInjector.convertMe(ArrayInjector.java:63)
	at org.nutz.mvc.adaptor.injector.ArrayInjector.get(ArrayInjector.java:51)
	at org.nutz.mvc.adaptor.AbstractAdaptor.adapt(AbstractAdaptor.java:288)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:25)
	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 cn.wizzer.app.web.commons.processor.XssSqlFilterProcessor.process(XssSqlFilterProcessor.java:35)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.app.web.commons.processor.NutShiroProcessor.process(NutShiroProcessor.java:52)
	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 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 cn.wizzer.app.web.commons.processor.GlobalsSettingProcessor.process(GlobalsSettingProcessor.java:44)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.app.web.commons.processor.LogTimeProcessor.process(LogTimeProcessor.java:21)
	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.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1621)
	at cn.wizzer.app.web.commons.filter.RouteFilter.doFilter(RouteFilter.java:28)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1621)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	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.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1613)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:541)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1592)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1239)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:481)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1561)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1141)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:118)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.Server.handle(Server.java:564)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
	at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:122)
	at org.eclipse.jetty.util.thread.strategy.ExecutingExecutionStrategy.invoke(ExecutingExecutionStrategy.java:58)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:201)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:133)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.nutz.lang.born.BorningException: Fail to born or cast to 'cn.wizzer.app.doc.modules.models.Doc_flow'
 by args: [@([{"documentId":"","codebar":"GB0626-2005^undefined0000^外交部^^12^^12^非密^无^20171208^^外交部亚洲司^20171208^^|","traceCode":"00018640000170070002","handleType":"4","rfid":"-58a89394:16034b333d8:-7e98","title":"12","docNo":"12","shareNo":"","bn":"00006","fromNodeId":"40280c9c5aff2ba8015aff7ed2f90015","toNodeId":"a4103ab966ae4a5c82bd87e197c6a5e6","status":"1","secret":"非密","urgent":"1","abnormity":"0","receiveEmployeeId":"0","sendEmployeeId":"64fa4ef015cc89bfd737fcf","type":"0","dropType":"0"}])]
 because: No suitable Constructor or Factory Method!!
	at org.nutz.lang.Mirror.born(Mirror.java:1008)
	at org.nutz.castor.castor.String2Object.cast(String2Object.java:16)
	at org.nutz.castor.castor.String2Object.cast(String2Object.java:9)
	at org.nutz.castor.Castors.cast(Castors.java:252)
	... 71 more
[DEBUG] 2017-12-08 21:29:04,678 org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.manage(JobStoreSupport.java:3877) - ClusterManager: Check-in complete.
11 回复
 {data:JSON.stringify(data)}
// 改成这样
JSON.stringify({'data':data})
 {data:JSON.stringify(data)}
// 改成这样
JSON.stringify({'data':data})

按你之前的写法

{data:JSON.stringify(data)}
// 发送的数据会是
data=[{"documentId":"","codebar":"GB0626-2005^undefined0000^外交部^^12^^12^非密^无^20171208^^外交部亚洲司^20171208^^|","traceCode":"00018640000170070002","handleType":"4","rfid":"-58a89394:16034b333d8:-7e98","title":"12","docNo":"12","shareNo":"","bn":"00006","fromNodeId":"40280c9c5aff2ba8015aff7ed2f90015","toNodeId":"a4103ab966ae4a5c82bd87e197c6a5e6","status":"1","secret":"非密","urgent":"1","abnormity":"0","receiveEmployeeId":"0","sendEmployeeId":"64fa4ef015cc89bfd737fcf","type":"0","dropType":"0"}]

之前的能跑? @AdaptBy(type = JsonAdaptor.class) 竟然会当成合法的json解析??

之前没有加这个: @AdaptBy(type = JsonAdaptor.class)
确实能跑的,更新1.63后,客户第一次远程访问报错的!我就加上这行代码还是报错的!
按照你的修改意见,flows=null

那就不要加 @AdaptBy(type = JsonAdaptor.class) 啊。。。

恢复你最初的写法,然后数组改成List试试

恢复到之前的方式,修改成List<>就可以了,但是[]就不可以!不兼容呀,

@shuxinyun 嗯,报个issue吧

如果把Doc_flow[]改成NutMap[]就又可以了!

好像是自定义对象不能以数组的方式接收参数!

反正是bug,报issue啦

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