Hello, I'm really at loss trying to track down the source of this
exception detailed below. I'm developing on Google's App Engine, and this exception seems to be specific to some internal App Engine method. I can't seem to track the source of the null pointer...since I'm not sure why the LobinCookieUtils are being called when I send the post request.

I hope I didn't post this in the wrong forum. It technically is Java Servlet, just more of an app engine specific problem.

Here is the exception:

Apr 19, 2011 11:53:47 AM com.google.apphosting.utils.jetty.JettyLogger
warn
WARNING: /_ah/login
java.lang.NullPointerException
at
com.google.appengine.api.users.dev.LoginCookieUtil s.encodeEmailAsUserId(LoginCookieUtils.java:
89)
at
com.google.appengine.api.users.dev.LoginCookieUtil s.createCookie(LoginCookieUtils.java:
41)
at
com.google.appengine.api.users.dev.LocalLoginServl et.doPost(LocalLoginServlet.java:
90)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(Ser vletHolder.java:
511)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1166)
at
com.google.appengine.api.blobstore.dev.ServeBlobFi lter.doFilter(ServeBlobFilter.java:
58)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.apphosting.utils.servlet.TransactionCle anupFilter.doFilter(TransactionCleanupFilter.java:
43)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.appengine.tools.development.StaticFileF ilter.doFilter(StaticFileFilter.java:
122)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
org.mortbay.jetty.servlet.ServletHandler.handle(Se rvletHandler.java:
388)
at
org.mortbay.jetty.security.SecurityHandler.handle( SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(Se ssionHandler.java:
182)
at
org.mortbay.jetty.handler.ContextHandler.handle(Co ntextHandler.java:
765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebA ppContext.java:
418)
at
com.google.apphosting.utils.jetty.DevAppEngineWebA ppContext.handle(DevAppEngineWebAppContext.java:
70)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(Ha ndlerWrapper.java:
152)
at com.google.appengine.tools.development.JettyContai nerService
$ApiProxyHandler.handle(JettyContainerService.java :351)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(Ha ndlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(Htt pConnection.java:
542)
at org.mortbay.jetty.HttpConnection
$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser. java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpPa rser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnec tion.java:404)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(Selec tChannelEndPoint.java:
409)
at org.mortbay.thread.QueuedThreadPool
$PoolThread.run(QueuedThreadPool.java:582)
This is occurring on my development server after running the app as a
Web Application through eclipse. The app basically stores .html files
in the blobstore, and allows the user to edit the html file through a
small jQuery based HTML editor.

I can retrieve the .html file contents from the blobstore using
fetchData to return a byte array of the contents. But once the user
has made changes to the html code via the editor, I'm trying to update
the entry in the DATASTORE that references the BlobKey string for the
corresponding .html file. So I am using a MultiPartFormOutputStream to
write directly to the request headers and simulate an HTTP POST
request.

Here is the code I have:

Java Code:
byte[] htmlData = content.getBytes();
                for(int k=0; k<htmlData.length; k++)
                {
                        resp.getWriter().println("Byte " + k + ": " + htmlData[k]);
                }
                BlobstoreService blobstoreService =
BlobstoreServiceFactory.getBlobstoreService();
                String uploadURL = blobstoreService.createUploadUrl("/upload");

                             //add host if in dev mode
                 if(uploadURL.indexOf("http") == -1)
                 {
                         uploadURL = "http://localhost:8888" + uploadURL;
                 }
                 URL url = new URL(uploadURL);
                 // create a boundary string
                 String boundary = MultiPartFormOutputStream.createBoundary();
                 URLConnection urlConn =
MultiPartFormOutputStream.createConnection(url);
                 urlConn.setReadTimeout(15000);
                 urlConn.setRequestProperty("Accept", "*/*");
                 urlConn.setRequestProperty("Content-Type",
MultiPartFormOutputStream.getContentType(boundary));
                 // set some other request headers...
                 urlConn.setRequestProperty("Connection", "Keep-Alive");
                 urlConn.setRequestProperty("Cache-Control", "no-cache");
                 // no need to connect because getOutputStream() does it
                 MultiPartFormOutputStream out = new
MultiPartFormOutputStream(urlConn.getOutputStream(), boundary);
                 // write a text field element - This should be removed - left over
from multipart library demo code
                 out.writeField("old", oldBlobKey);
                 out.writeField("lob", lineOfBusiness);
                 out.writeField("topic", topic);
                 out.writeField("category", category);
                 out.writeField("key", key);
                 // write bytes directly
                 out.writeFile("myFile", "application/octet-stream", "content.html",
htmlData);
                 out.close();

                 // read response from server

                 BufferedReader responseIn = new BufferedReader(new
InputStreamReader(urlConn.getInputStream()));
                 StringBuilder redirectResponse = new StringBuilder();
                 String line="";
                 while((line = responseIn.readLine()) != null)
                 {
                      redirectResponse.append(line);
                 }
                 resp.getWriter().println(redirectResponse);
Essentially the user is directed to a servlet with this code upon
clicking the Update button on the HTML editor. The POST data is then
passed along via the MultiPartFormOutputStream to another servlet
called Upload.

Here is the code for Upload:

Java Code:
public class Upload extends HttpServlet
{
    private BlobstoreService blobstoreService =
BlobstoreServiceFactory.getBlobstoreService();

    public void doPost(HttpServletRequest req, HttpServletResponse
res) throws ServletException, IOException
    {
        Map<String, BlobKey> blobs =
blobstoreService.getUploadedBlobs(req);
        BlobKey blobKey = blobs.get("myFile");
        String content = blobKey.getKeyString();
        String oldKeyStr = req.getParameter("old");
        BlobKey oldKey = new BlobKey(oldKeyStr);
        String lineOfBusiness = req.getParameter("lob");
        String topic = req.getParameter("topic");
        String category = req.getParameter("category");
        Long key = Long.parseLong(req.getParameter("key"));
        //delete old blob
        blobstoreService.delete(oldKey);
        //First, grab the old object.
                PersistenceManager pm = PMF.get().getPersistenceManager();
                Topic t = pm.getObjectById(Topic.class, key);
                t.setContent(content);
                t.setLineOfBusiness(lineOfBusiness);
                t.setTopic(topic);
                t.setCategory(category);
                try
                {
                        pm.makePersistent(t);
                }
                finally
                {
                        pm.close();
                }
                res.sendRedirect("topics.jsp");
    }
}