title: google app engine cron backend java always give an error
body: <p>I have a servlet code like this :</p>
  
  <pre><code>public class BackendServlet extends HttpServlet {
     private static final Logger LOG = Logger.getLogger(BackendServlet.class.getName());
     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        doPost(req, resp);
     }
  
     protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        LOG.info("just test backend");
     }
  }
  </code></pre>
  
  <p>Then I have a <strong>web.xml</strong> that looks like following :</p>
  
  <pre><code>  &lt;servlet&gt;
       &lt;servlet-name&gt;update&lt;/servlet-name&gt;
        &lt;servlet-class&gt;com.google.api.test.backend.BackendServlet&lt;/servlet-class&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;update&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/updatebackend&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
    &lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;update&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/updatebackend&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;
      &lt;auth-constraint&gt;
          &lt;role-name&gt;admin&lt;/role-name&gt;
      &lt;/auth-constraint&gt;
    &lt;/security-constraint&gt;
  
    &lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
        &lt;web-resource-name&gt;any&lt;/web-resource-name&gt;
        &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;
      &lt;auth-constraint&gt;
        &lt;role-name&gt;*&lt;/role-name&gt;
      &lt;/auth-constraint&gt;
    &lt;/security-constraint&gt;
  </code></pre>
  
  <p>Then I have the <strong>cron.xml</strong> and <strong>backend.xml</strong> that looks like following :</p>
  
  <p><strong>cron.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;cronentries&gt;
    &lt;cron&gt;
      &lt;url&gt;/updatebackend&lt;/url&gt;
      &lt;description&gt;Update on the backend&lt;/description&gt;
      &lt;schedule&gt;every 5 minutes&lt;/schedule&gt;
      &lt;target&gt;updatebackend&lt;/target&gt;
    &lt;/cron&gt;
  &lt;/cronentries&gt;
  </code></pre>
  
  <p><strong>backend.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;backends&gt;
      &lt;backend name="updatebackend"&gt;
          &lt;class&gt;B1&lt;/class&gt;
          &lt;options&gt;
              &lt;dynamic&gt;true&lt;/dynamic&gt;
          &lt;/options&gt;
      &lt;/backend&gt;
  &lt;/backends&gt;
  </code></pre>
  
  <p>But when I upload this to app engine server. it always gave me below error message :</p>
  
  <blockquote>
    <p>/_ah/start java.lang.NullPointerException     at
    com.google.api.client.extensions.appengine.auth.oauth2.AbstractAppEngineAuthorizationCodeServlet.getUserId(AbstractAppEngineAuthorizationCodeServlet.java:92)</p>
  </blockquote>
  
  <p>How can I run the servlet using cron job on the app engine backend correctly? Is there any setup above that I do wrong?</p>
  
  <p>Thanks.</p>