JFinal-weixin-1.2框架怎么报了这个错???

sgt186 发布于 2016/03/15 17:24
阅读 541
收藏 0
接收消息:
<xml><ToUserName><![CDATA[gh_b54935705fe8]]></ToUserName>
<FromUserName><![CDATA[otodvt5JF7XjgMMNlWviRr5bmAZ4]]></FromUserName>
<CreateTime>1458032848</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[subscribe]]></Event>
<EventKey><![CDATA[last_trade_no_1003940121201603113906347438]]></EventKey>
</xml>


[QC] ERROR [http-80-6] com.jfinal.core.ActionHandler.handle(123) | /weixin?signature=f16ed850899d31cba3d75b95c757678e9f4cda70&timestamp=1458032848&nonce=1978457148
java.lang.RuntimeException: 无法识别的事件类型,请查阅微信公众平台开发文档
at com.jfinal.weixin.sdk.msg.InMsgParaser.parseInEvent(InMsgParaser.java:192)
at com.jfinal.weixin.sdk.msg.InMsgParaser.doParse(InMsgParaser.java:72)
at com.jfinal.weixin.sdk.msg.InMsgParaser.parse(InMsgParaser.java:36)
at com.jfinal.weixin.sdk.jfinal.MsgController.getInMsg(MsgController.java:126)
at com.jfinal.weixin.sdk.jfinal.MsgController.index(MsgController.java:57)
at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:55)
at com.jfinal.weixin.sdk.jfinal.MsgInterceptor.intercept(MsgInterceptor.java:46)
at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:51)
at com.interceptor.PofInterceptor.intercept(PofInterceptor.java:91)
at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:51)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:73)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:701)


这是什么原因啊,请波大大看看!

加载中
0
JFinal
JFinal

    由于微信平台出现 bug:subscribe/unsubscribe 关注事件在有些时候居然会出现 eventKey 值,例如:eventKey为last_trade_no_4003942001201604205023621558,所以会出现这个异常,jfinal weixin 已更新相关代码,包容了微信平台的这个 bug,建议去 git.oschina.net下载最新版本打包再使用。

    附上微信平台有关关注与取消关注的开发文档:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140454&token=&lang=zh_CN

    另外再附上与微信平台bug相关的xml:

<xml>
  <EventKey>
  <![CDATA[last_trade_no_4003942001201604205023621558]]>
  </EventKey>
</xml>

1
sgt186
sgt186

引用来自“JFinal”的评论

    由于微信平台出现 bug:subscribe/unsubscribe 关注事件在有些时候居然会出现 eventKey 值,例如:eventKey为last_trade_no_4003942001201604205023621558,所以会出现这个异常,jfinal weixin 已更新相关代码,包容了微信平台的这个 bug,建议去 git.oschina.net下载最新版本打包再使用。

    附上微信平台有关关注与取消关注的开发文档:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140454&token=&lang=zh_CN

    另外再附上与微信平台bug相关的xml:

<xml>
  <EventKey>
  <![CDATA[last_trade_no_4003942001201604205023621558]]>
  </EventKey>
</xml>

是的,如果不更换框架,可在源码包里的com.jfinal.weixin.sdk.msg.InMsgParaser.parseInEvent()方法里修改,如下:

if (("subscribe".equals(event) || "unsubscribe".equals(event)) && StrKit.isBlank(eventKey)) {


修改成
if (("subscribe".equals(event) || "unsubscribe".equals(event)) && (StrKit.isBlank(eventKey) || eventKey.startsWith("last_trade_no_"))) {


注意:该修改方法只能治标,治本还是下载最新版本的jfinal-weixin
返回顶部
顶部