Cannot forward after response has been committed

<returnForm><type>2</type><count>1</count><list><pushSmsForm><eprId>1730</eprId><mobile>18042324660</mobile><msgId></msgId><content><![CDATA[HV:20FV:19PV:15MJN:closedMJW:closedBATT:6.1VSIG: 0Address:11111SN:00E3]]></content><userId>szcdsfxx</userId><extNum>61730</extNum><recvNum>1069046861730</recvNum></pushSmsForm></list></returnForm>
Sql: select * from sms_auth where deleteSign=? and authKey=?

JFinal action report -------- 2018-07-31 17:29:43 ------------------------------
Controller  : com.locman.sms.api.controller.ApiController.(ApiController.java:1)
Method      : recive
UrlPara     : c6cf96ae704611e8acef02004c4f4f50
Interceptor : com.locman.sms.api.interceptor.ERROR.(ERROR.java:1)
--------------------------------------------------------------------------------
2018-07-31 17:29:43 ERROR [http-nio-4567-exec-6] com.jfinal.core.ActionHandler  - /api/recive/c6cf96ae704611e8acef02004c4f4f50
java.lang.NullPointerException
        at org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:180)
        at com.jfinal.render.TextRender.render(TextRender.java:59)
        at com.jfinal.core.ActionHandler.handle(ActionHandler.java:97)
        at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:322)
        at org.apache.catalina.ha.session.JvmRouteBinderValve.invoke(JvmRouteBinderValve.java:193)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        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)
2018-07-31 17:29:43 ERROR [http-nio-4567-exec-6] com.jfinal.core.JFinalFilter  - /api/recive/c6cf96ae704611e8acef02004c4f4f50
com.jfinal.render.RenderException: java.lang.IllegalStateException: Cannot forward after response has been committed
        at com.jfinal.render.JspRender.render(JspRender.java:69)
        at com.jfinal.render.ErrorRender.render(ErrorRender.java:51)
        at com.jfinal.core.ActionHandler.handle(ActionHandler.java:130)
        at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:322)
        at org.apache.catalina.ha.session.JvmRouteBinderValve.invoke(JvmRouteBinderValve.java:193)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        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)
Caused by: java.lang.IllegalStateException: Cannot forward after response has been committed
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:321)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)
        at com.jfinal.render.JspRender.render(JspRender.java:67)
        ... 24 more


相关代码:

Controller

	public void recive() {
		String authKey = getPara();
		String content = getBodyContent();
		String other = getPara("channel");

		boolean isAuthValid = smsAuthDao.checkKey(authKey);
		if (!isAuthValid) {
			renderText("AuthKey不能为空或者错误!");
			return;
		}
		String result = smsRecive.recive(authKey, content, other);
		renderText(result);
	}


拦截器:

package com.locman.sms.api.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.kit.LogKit;
import com.locman.sms.biz.bean.ResponseBean;

public class ERROR implements Interceptor {

	@Override
	public void intercept(Invocation inv) {
		try {
			inv.invoke();
		} catch (Exception e) {
			LogKit.error("服务器错误", e);
			inv.getController().renderJson(ResponseBean.code_3_error(null, "接口错误"));
			return;
		}
	}
}


使用JFinal2.2版本,以前很少出现这类情况,今天线上环境出现了这个情况,不知道什么原因引起的。

评论区

JFinal

2018-07-31 17:46

这个是空指针异常,根据异常提示,调试一下是哪个对象为 null 引起的

热门反馈

扫码入社