Leaderboard exception org.json.JSONException: JSONObject["appErrorCode"] not a string.

0 votes

I am using App42 leaderboard service, and facing the following exception sometime when I save user score.

 18:45:23.960 com.shephertz.app42.paas.sdk.java.App42Exception: org.json.JSONException: JSONObject["appErrorCode"] not a string.
» 18:45:23.960 at com.shephertz.app42.paas.sdk.java.game.ScoreBoardService.saveUserScore(ScoreBoardService.java:114)
» 18:45:23.960 at models.leaderboard.TVShowLeaderboardDao.saveUserScore(TVShowLeaderboardDao.java:106)
» 18:45:23.960 at com.evertest.activemq.consumer.TVShowLeaderboardConsumer.consumerStart(TVShowLeaderboardConsumer.java:55)
» 18:45:23.960 at com.evertest.activemq.consumer.TVShowLeaderboardConsumer.run(TVShowLeaderboardConsumer.java:74)
» 18:45:23.960 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
» 18:45:23.960 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
» 18:45:23.960 at java.util.concurrent.FutureTask.run(FutureTask.java:166)
» 18:45:23.960 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
» 18:45:23.960 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
» 18:45:23.960 at java.lang.Thread.run(Thread.java:722)
» 18:45:23.960 Caused by: org.json.JSONException: JSONObject["appErrorCode"] not a string. Exception
» 18:45:23.960 at org.json.JSONObject.getString(JSONObject.java:644)
» 18:45:23.960 at com.shephertz.app42.paas.sdk.java.connection.RESTConnectorAsync.handleException(RESTConnectorAsync.java:325) Exception
» 18:45:23.960 at com.shephertz.app42.paas.sdk.java.connection.RESTConnectorAsync.executePost(RESTConnectorAsync.java:132)
» 18:45:23.960 at com.shephertz.app42.paas.sdk.java.game.ScoreBoardService.saveUserScore(ScoreBoardService.java:108)
» 18:45:23.960 ... 9 more
I just switch to App42_JAVA_SDK_2.5.jar from 2.4.1, but it didn't solve the issue.
Any idea on this?

 

asked Feb 6, 2015 in App42 Cloud API-BaaS by tianyi (15 points)

1 Answer

0 votes

Hello Tianyi,

Can you please let us know the complete message of exception that you are getting in the console? You can enable logging using following call after you initialize App42 API.

App42Log.setDebug(true);

Thanks,

Himanshu Sharma

answered Feb 6, 2015 by hs00105 (2,005 points)
I just faced the error when create a game. Following is the log:

2015-02-17 10:55:35,243 INFO  [play-thread-1] (TVShowLeaderboardDao.java:66) --- Create new tvshow leaderboard, tvshowUUID: 82d06a00-348a-41c1-8924-7ff9048053ea, tvshowTitle: Bad Girls All Star Battle
2015-02-17 10:55:35,250 INFO  [play-thread-1] (LoggingOutputStream.java:54) ---  Json String : {"app42":{"game":{"description":"Bad Girls All Star Battle","name":"82d06a00-348a-41c1-8924-7ff9048053ea"}}}
2015-02-17 10:55:35,253 INFO  [play-thread-1] (LoggingOutputStream.java:54) --- Post URL is https://api.shephertz.com/cloud/1.0/game?
2015-02-17 10:55:35,254 INFO  [play-thread-1] (LoggingOutputStream.java:54) ---  Setting Header value : signature : H3ccATXVXXrBgQ6KSZRBDBP30%2BM%3D
2015-02-17 10:55:35,254 INFO  [play-thread-1] (LoggingOutputStream.java:54) ---  Setting Header value : version : 1.0
2015-02-17 10:55:35,254 INFO  [play-thread-1] (LoggingOutputStream.java:54) ---  Setting Header value : SDKName : Java
2015-02-17 10:55:35,254 INFO  [play-thread-1] (LoggingOutputStream.java:54) ---  Setting Header value : timeStamp : 2015-02-17T15:55:35.246Z
2015-02-17 10:55:35,254 INFO  [play-thread-1] (LoggingOutputStream.java:54) ---  Setting Header value : apiKey : 63cccd5ab4549fe596e99d7d963558341eabf0c53a5552e589eb009640d9d4e5
2015-02-17 10:55:36,060 INFO  [play-thread-1] (Bootstrap.java:268) --- Exception in Bootstrap:org.json.JSONException: JSONObject["appErrorCode"] not a string.
com.shephertz.app42.paas.sdk.java.App42Exception: org.json.JSONException: JSONObject["appErrorCode"] not a string.
    at com.shephertz.app42.paas.sdk.java.game.GameService.createGame(GameService.java:101)
    at models.leaderboard.TVShowLeaderboardDao.createNewTVShowLeaderboard(TVShowLeaderboardDao.java:67)
    at Bootstrap.doJob(Bootstrap.java:75)
    at play.jobs.Job.doJobWithResult(Job.java:53)
    at play.jobs.Job$2.apply(Job.java:196)
    at play.db.jpa.JPA.withTransaction(JPA.java:234)
    at play.db.jpa.JPA.withinFilter(JPA.java:195)
    at play.db.jpa.JPAPlugin$TransactionalFilter.withinFilter(JPAPlugin.java:299)
    at play.jobs.Job.withinFilter(Job.java:175)
    at play.jobs.Job.call(Job.java:194)
    at play.jobs.Job.run(Job.java:169)
    at play.jobs.JobsPlugin.afterApplicationStart(JobsPlugin.java:116)
    at play.plugins.PluginCollection.afterApplicationStart(PluginCollection.java:521)
    at play.Play.start(Play.java:558)
    at play.Play.detectChanges(Play.java:653)
    at play.Invoker$Invocation.init(Invoker.java:198)
    at play.server.PlayHandler$NettyInvocation.init(PlayHandler.java:205)
    at play.Invoker$Invocation.run(Invoker.java:287)
    at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:245)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: org.json.JSONException: JSONObject["appErrorCode"] not a string.
    at org.json.JSONObject.getString(JSONObject.java:658)
    at com.shephertz.app42.paas.sdk.java.connection.RESTConnectorAsync.handleException(RESTConnectorAsync.java:329)
    at com.shephertz.app42.paas.sdk.java.connection.RESTConnectorAsync.executePost(RESTConnectorAsync.java:132)
    at com.shephertz.app42.paas.sdk.java.game.GameService.createGame(GameService.java:95)
    ... 25 more

Let me know if this help. Thanks
Hello Tianyi,

Thanks for sharing the logs with us. Kindly find the latest binary from the below link & let me know if it helps.
https://github.com/shephertz/App42_JAVA_SDK/archive/master.zip

Himanshu Sharma
I already upgrade from 2.4 to 2.5, now I see the latest version become 2.5.1. I'll give it a try, but I don't whether this gonna help. Help you ever see the same problem before?
Hello Tianyi,

Have your issue is resolved. Kindly let us know for the same.
Thanks,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...