4
votes

I wrote a small application working on local environment without any problems but however after i deployed the app to Google App Engibe, it stopped working. Here's the code on client side :

    CollectionResponseLong asd = null;
    try {
        asd = getEndpoint().getClosePeople(id).execute();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

I can see that it Works on the server side as well with the following code :

@SuppressWarnings({ "unchecked", "unused" })
@ApiMethod(name = "getClosePeople",path = "getClosePeople")
public CollectionResponse<Long> getClosePeople(@Named("id") Long id)    {

    PersistenceManager mgr = getPersistenceManager();
    Cursor cursor = null;
    List<Long> execute = null;
    String cursorString = null; 
    Integer limit = null; 

        User user = mgr.getObjectById(User.class, id);
    mgr = getPersistenceManager();
    Query query = mgr.newQuery(User.class);
    if (cursorString != null && cursorString != "") {
        cursor = Cursor.fromWebSafeString(cursorString);
        HashMap<String, Object> extensionMap = new HashMap<String, Object>();
        extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, cursor);
        query.setExtensions(extensionMap);
    }

//  query.setFilter("GeoHash == '" + user.getGeoHash() +"'" + " && Id != " + id);
    query.setFilter("GeoHash == '" + user.getGeoHash() +"'" + " && Id != " + id);
    query.setResult("Id");

    if (cursorString != null && cursorString != "") {
        cursor = Cursor.fromWebSafeString(cursorString);
        HashMap<String, Object> extensionMap = new HashMap<String, Object>();
        extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, cursor);
        query.setExtensions(extensionMap);
    }

    if (limit != null) {
        query.setRange(0, limit);
    }
    execute = (List<Long>) query.execute();
    cursor = JDOCursorHelper.getCursor(execute);
    if (cursor != null)
        cursorString = cursor.toWebSafeString();
    for (Long obj : execute)
        ;
    System.out.println("STRING " + execute.toString());


    mgr.close();


    System.out.println(CollectionResponse.<Long> builder().setItems(execute)
    .setNextPageToken(cursorString).build().getItems().toString());


    return CollectionResponse.<Long> builder().setItems(execute)
            .setNextPageToken(cursorString).build();

    }   

I can see in the logs on server side that there are no problems until return statement because System.out prints the response i want. But i get the following error on eclipse, and also the interesting thing is there is no error log on Google app engine admin console

com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error :

Application name is not set. Call Builder#setApplicationName. com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error { "code" : 500, "errors" : [ { "domain" : "global", "message" : "Internal Error", "reason" : "internalError" } ], "message" : "Internal Error" } at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:312) at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1045) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)

Thanks,

I HAVE FOUND THE SOLUTION, I HOPE IT WILL HELP PEOPLE FACING THE SAME ISSUE :)

Simply you can not use String as return. That's it. Eventhough it works on development environment without any problems, it won't work after deployment (on Google production environment). I have created two seperate objects for this purpose, one for String and one for String[] named StringObject and StringArrayObject, and i use these methods whenever i want to return arrays or strings.

2
is the app-id correctly set in the appengine-web.xml file? - nebulae
I encountered Google API 500 error today, after wait for few hours than working again. - Fruit

2 Answers

0
votes

The message "Application name is not set" suggests that internally on AppEngine, a variable that is meant to contain the application id probably contains a null. As @nebulae commented, the place to check that would be appengine-web.xml. The application deployed however, so the application id is probably not empty. In Eclipse the place to look is project Properties -> Google -> AppEngine -> Deployment of course.

Some text in the first sentence of the question is corrupt and suggests problems with character sets: "Google App Ebgşbe" instead of "Google App Engine". Now if deployment works, but the production runtime crashes, there may be some characters in the application id that deployment can handle but the runtime cannot.

Therefore I suggest you create a different application id consisting of only definitely safe characters, update the project properties with that, and try deploying and running again.

0
votes

I wasn't able to find the solution, so I added a 3 times retry on the cloudEndpoint.getResult() method. Whenever it fails randomly, it mostly works in the second retry.