In Google App Engine Java, i am trying to run backend but i always get Error message in backends log..

Process terminated because it failed to respond to the start request with an HTTP status code of 200-299 or 404.

App Engine Logs

2014-12-07 11:06:31.944 /_ah/start 302 4842ms 0kb instance=0 module=default version=testservice
0.1.0.3 - - [06/Dec/2014:21:36:31 -0800] "GET /_ah/start HTTP/1.1" 302 231 - - "0.testservice.testapp.appspot.com" ms=4842 cpu_ms=7626 cpm_usd=0.000026 loading_request=1 exit_code=107 instance=0 app_engine_release=1.9.16 

com.test.AppFilter doGet: Filter Initiated..!

This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application. E 2014-12-05 11:02:16.916

Process terminated because it failed to respond to the start request with an HTTP status code of 200-299 or 404.

Please Help.

2

There are 2 answers

1
David On BEST ANSWER

When a module (or the former version : backend) starts, the Google App Engine orchestrator sends an HTTP request to /_ah/start. You can use this HTTP request to perform any initialization operation you wish.

This HTTP request, as explained in the log messages, must return an HTTP status code either between 200 and 299 (which tells that the request was correctly processed) or 404 Not Found (which tells that you did not attach any servlet or filter to this request).

All this is explained in Google's documentation at this page.

Here the answer was 302 Redirect. This is usually trigerred by a security filter that redirects to an authentication screen.

If you defined a custom security filter or a servlet that handles the /_ah/start URL, makes sure it returns a 200 HTTP code.

If you set a <security-constraint> on this URL (apart to force SSL), remove it.

0
Craig D On
Process terminated because it failed to respond to the start request with an HTTP status code of 200-299 or 404.

The error message above is a catch all for anything that causes a failure in either warm up or start up. Basically, if the doGet of the /_ah/start doesn't complete with one of those HTTP status codes, this error is generated.

Something I didn't understand in searching for the root cause is that the /_ah/start Servlet doesn't complete first (serially) prior to the warmup or context initialization (CI) process completing. That is, context initialization runs as a dependency of the start Servlet, meaning that if it (CI) fails, the entire start fails, generating the above message.

Unfortunately, the message doesn't provide much of a hint as to where the root cause lies. If you have a context listener for example, such as annotated as a @WebListener, and the contextInitialized(ServletContextEvent sce) method doesn't complete successfully (crashes, generates stack trace), then that issue could be the root cause of this error.

The simplest way to locate the issue is check the logs for any stack trace, starting with warning messages in the log. That is, see if any start, warm-up or context initialization code is crashing. If you find an issue, fix it.

Below is an example definition working in a Java-Gen2 Legacy Bundled Services configuration (once the context initialization issues were fixed).

@WebServlet(name = "StartUpHttpHandlerServlet", description = "Startup Http Handler Servlet", urlPatterns = {"/_ah/start"})
public class StartUpHttpHandlerServlet extends HttpServlet  {

        @Override
        public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {        
        
            resp.setStatus(200);
        }
     }
 }

This document nicely describes the start process, but doesn't specifically get into what may cause the error message above.