2
votes

I have a Java application on Google App Engine with a servlet that loads large images from Google Cloud Storage. This code did work (like... yesterday) and it won't anymore for some reason, but I didn't edit it! While refreshing several time, it once returned about half of the image it's supposed to load, then stopped.

Here is the servlet:

@SuppressWarnings("serial")
public class SomeServlet extends HttpServlet
{
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
    {
        BlobstoreService blobstore = BlobstoreServiceFactory.getBlobstoreService();
        String file = req.getParameter("file");
        String folder = req.getParameter("folder");

        BlobKey blobkey = blobstore.createGsBlobKey("/gs/bucket/" + folder + "/" + file + ".jpg");

        blobstore.serve(blobkey, resp);
    }
}

Here is what the log says, without any warning/error/critical flags:

2012-07-26 19:44:54.635 /servlet?folder=SomeFolder&file=SomeFile 200 96ms 0kb Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1 [26/Jul/2012:10:44:54 -0700] "GET /servlet?folder=SomeFolder&file=SomeFile HTTP/1.1" 200 334 - "Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1" "myapp.appspot.com" ms=97 cpu_ms=103 api_cpu_ms=33 cpm_usd=0.002957 instance=00c61b117cef9993f79be3c568c0cbda0f14

Here is what http://myapp.appspot.com/servlet?folder=SomeFolder&file=SomeFile displays:

Error: Server Error The server encountered an error and could not complete your request. If the problem persists, please report your problem and mention this error message and the query that caused it.

Any ideas?

Thanks!

2

2 Answers

0
votes

I suggest the following to figure out the exact problem:

  • Put a try/catch in your doGet and in the catch Exception handler, log the error message or write that out on the screen.
0
votes

Are you sure that you app has access to the bucket that your trying to serve files from? The service account from your application needs to have at least read permissions on the objects you;re trying to serve.

The actual serving of the file happens outside of your servlet which is why you don't see anything in your logs.