Note that there are some explanatory texts on larger screens.

plurals
  1. POgetting 500 from Blobstore
    primarykey
    data
    text
    <p>Here is a bulleted list of events:</p> <ul> <li>My android app sends blobs to Blobstore.</li> <li>From app-engine console, I can see my blobs in <code>Blob Viewer</code> so I know my blobs got saved</li> <li>But Blobstore does not invoke callback url, but instead</li> <li>Blobstore returns 500 to my android app</li> </ul> <p>So I cannot get blob keys to my datastore.</p> <p>code to do http post <code>myImage</code> is a byte array:</p> <pre><code>HttpClient httpClient = new DefaultHttpClient(); HttpPost postRequest = new HttpPost(url); MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); try { reqEntity.addPart("title", new StringBody(title)); reqEntity.addPart("caption", new StringBody(caption)); ByteArrayBody myBlob = new ByteArrayBody(myImage, "myImage.png"); reqEntity.addPart("myBlob", myBlob); ByteArrayBody secBlob = new ByteArrayBody(secBlobImage, "secBlobImage.png"); reqEntity.addPart("secBlob", secBlob); } catch (Exception e) { e.printStackTrace(); } postRequest.setEntity(reqEntity); try { HttpResponse response = httpClient.execute(postRequest); System.out.println("RESPONSE CODE::: " + response.getStatusLine().getStatusCode()); System.out.println("REASON CODE::: " + response.getStatusLine().getReasonPhrase()); } catch (Exception e) { e.printStackTrace(); } </code></pre> <p>After android initiates the call to the blobstore, I get the following rant from logCat:</p> <pre><code>04-30 00:59:15.922: I/APACHE HTTP (thCr=4674) - NafHttpAuthStrategyDefault(8796): (thUse=4674) NafHttpAuthStrategyDefault() 04-30 00:59:15.922: I/APACHE HTTP (thCr=4674) - KeeperManager(8796): (thUse=4674) INITIALIZATION of shared resources 04-30 00:59:15.922: I/APACHE HTTP (thCr=4674) - AndroidContextProviderImpl(8796): (thUse=4674) currentActivityThread=null 04-30 00:59:15.930: I/APACHE HTTP (thCr=4674) - GbaSupportIndicatorRequestUpdaterDefault(8796): (thUse=4674) GbaSupportIndicatorRequestUpdaterAbstract() userHeaderPredefined=Apache-HttpClient/UNAVAILABLE (java 1.4) 04-30 00:59:15.946: I/APACHE HTTP (thCr=4674) - NafHttpAuthStrategyDefault(8796): (thUse=4674) cached value : gbaSupportIsPossible=null 04-30 00:59:15.946: I/APACHE HTTP (thCr=4674) - NafHttpAuthStrategyDefault(8796): (thUse=4674) The current context is NOT a context of GBA service. 04-30 00:59:15.946: I/APACHE HTTP (thCr=4674) - GbaSupportPermissionRequestCheckerImpl(8796): (thUse=4674) isCurrentProcessRequestedGba()#finished result=false 04-30 00:59:15.946: I/APACHE HTTP (thCr=4674) - GbaSupportPermissionRequestCheckerImpl(8796): (thUse=4674) isCurrentProcessAllowedToUseGba()#started result=false 04-30 00:59:15.946: I/APACHE HTTP (thCr=4674) - NafHttpAuthStrategyDefault(8796): (thUse=4674) The GBA permission wasn't requested for this process. 04-30 00:59:15.954: I/APACHE HTTP (thCr=4674) - NafHttpAuthStrategyDefault(8796): (thUse=4674) It is impossible to support GBA now (many possible reasons: no Android Context, current client is GBA service, etc.), then it will be just usual HTTP. 04-30 00:59:15.954: I/APACHE HTTP (thCr=4674) - NafRequestExecutorWrapperRedirectionHandler(8796): (thUse=4674) It isn't GBA flow, redirection responses are not handled. 04-30 00:59:20.688: I/APACHE HTTP (thCr=4674) - NafHttpAuthStrategyDefault(8796): (thUse=4674) cached value : gbaSupportIsPossible=false 04-30 00:59:20.688: I/System.out(8796): RESPONSE CODE::: 500 04-30 00:59:20.696: I/System.out(8796): REASON CODE::: Internal Server Error </code></pre> <p>EDIT:</p> <p>Many thanks to @Teshte and @ShivanRaptor for the question. I assumed my server was not being hit. But their question made me realize that indeed it was. So when I look at the server log, I find that there is a <code>java.lang.NullPointerException</code> at <code>BlobKey titleKey = blobs.get("title").get(0)</code> in the following code. The NPE occurs on the element that android is sending as <code>StringBody</code>. I haven't figured how to fix the NPE yet.</p> <p>Code:</p> <pre><code>public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); Map&lt;String, List&lt;BlobKey&gt;&gt; blobs = blobstoreService.getUploads(req); BlobKey titleKey = blobs.get("title").get(0); … res.sendRedirect("/"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload