Google App Engine- java.lang.IllegalStateException: Committed Error

天大地大妈咪最大 提交于 2020-01-04 02:18:08

问题


I'm currently working on an application that require me to deploy onto Google App Engine Server. My application runs perfectly fine locally on port 7777. However, when I deploy onto GAE, It starts to give me this error -

java.lang.IllegalStateException: Committed 

and it just returns me a "null" in the GAE log.

There's no error. It only state a warning message:

"A serious problem was encountered with the process that handled this request, causing it to exit. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may be throwing exceptions during the initialization of your application. (Error code 104)"

Hope someone can help me with this. Thanks in advance!


回答1:


This java.lang.IllegalStateException: Committed error often occurs when the HttpServletResponse is commited twice. For example :

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    if (trueCondition)
        resp.sendRedirect("/");
    if (otherTrueCondition)
        resp.sendRedirect("/other");
}



回答2:


somehow having 2 sendRedirect() is causing the problem when the servlet is parsed. try to modify the logic to have only one sendRedirect() in your code. I had a similar situation with a local jetty server. GAE runs in jetty!



来源:https://stackoverflow.com/questions/4162977/google-app-engine-java-lang-illegalstateexception-committed-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!