Jfinal Weixin调用接口报错

码农100 发布于 2018/09/23 20:06
阅读 412
收藏 0

在处理菜单点击事件的方法里 WeixinMsgController.processInMenuEvent ,调用CustomServiceApi.sendMpNews,发送图文消息报下面的错误,信息能正常接收到,什么原因

 

SEVERE: /jwx/msg?signature=d8e707c605aa05633ae508908527749f2e65e180&timestamp=1537689035&nonce=1093934862&openid=o6fbwt0kWHoj4qYaq8I8YsP5ACI8
java.lang.RuntimeException: File not found : /var/www/ryj/tomcat7/webapps/ROOT/jwx/msg/index.html
        at com.jfinal.template.source.FileSource.getContent(FileSource.java:70)
        at com.jfinal.template.Engine.buildTemplateBySourceFactory(Engine.java:154)
        at com.jfinal.template.Engine.getTemplate(Engine.java:139)
        at com.jfinal.render.TemplateRender.render(TemplateRender.java:61)
        at com.jfinal.core.ActionHandler.handle(ActionHandler.java:103)
        at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

Sep 23, 2018 3:50:35 PM com.jfinal.core.JFinalFilter error
SEVERE: /jwx/msg?signature=d8e707c605aa05633ae508908527749f2e65e180&timestamp=1537689035&nonce=1093934862&openid=o6fbwt0kWHoj4qYaq8I8YsP5ACI8
java.lang.IllegalStateException: getOutputStream() has already been called for this response
        at org.apache.catalina.connector.Response.getWriter(Response.java:636)
        at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:213)
        at com.jfinal.render.ErrorRender.render(ErrorRender.java:59)
        at com.jfinal.core.ActionHandler.handle(ActionHandler.java:141)
        at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

加载中
0
小塔罗
小塔罗

报错已经提示了一切 

0
yoke白板
yoke白板

报错都看不懂 写代码干嘛呢

0
JFinal
JFinal

controller 中调用完 CustomServiceApi.sendMpNews(...) 这个方法后,里面再加个  renderNull() 或者共它类型的 render 系的方法都可以

 

如果你的 contoller 继承了 MsgController,里面一些抽象方法是会接收到一些微信客户端的一些事件的,而这些方法内部你没有调用过任何 render 系的方法,那么 jfinal 会默认帮你调用一个 render(view) 规则如下:

String view = baseViewPath + basePath + methodName + ".html";
render(view);

   其中 baseViewPath 是通过routes.setBaseViewPath(...) 配置的,如果不配置则默认为项目 webapp 根目录。而 basePath 是映射 controller 时配置的,如果不配置默认为 controllerKey

 

    如果你的 controller 继承的 ApiController,那么在你的 action 中没有调用任何 render 系的方法也会出现上面一样的情况,只不过这种情况更好去发现

    解决办法极其简单,找到这些地方,调用任何一个 render 系的方法即可,如果不需要返回值,则调用  renderNull()

返回顶部
顶部