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.