Internal Server Error when upload .jar to Custom code

0 votes


I write code on java for sending push notifications to users who did not go to the game more than a day. I worked in Eclipse Mars, OSX 10.11.2.  Here is code (without libs):



public class Main {
	 * Main Method Send Push Notification from Cloud
	 * @param args
	public static final void main(String[] args) {
	static final void getRecipients() {
		long currentTimeInMinutes = Clock.systemUTC().millis()/60000;
		String dbName = "...";  
		String collectionName = "..."; 
		StorageService storageService = App42API.buildStorageService();
		Storage storage = storageService.findAllDocuments(dbName,collectionName);    

		ArrayList<Storage.JSONDocument> jsonDocList = storage.getJsonDocList();  
		for(int i=0;i<jsonDocList.size();i++)  
		    String jsonString = jsonDocList.get(i).getJsonDoc();
		    String docID = jsonDocList.get(i).getDocId();
		    JSONObject jobj = null;
			try {
				jobj = new JSONObject(jsonString);
			} catch (JSONException e) {
		    long lastLoadedTime = 0;
			try {
				lastLoadedTime = jobj.getLong("lastLoadedTime");
			} catch (JSONException e) {
		    if(currentTimeInMinutes - lastLoadedTime > 1440)
				try {
					storage = storageService.addOrUpdateKeys(dbName,collectionName,docID,jobj);
				} catch (JSONException e) {

	static final void sendPN(String userName) {
		String message = "Get free BribeMe, extra points or double time for bonuses!";
		PushNotificationService pushNotificationService = App42API.buildPushNotificationService();
		pushNotificationService.sendPushMessageToUser(userName, message);



I checked with the local computer everything works well. But I can't upload this to Custom code. If I make .jar using Eclipse, I get the message "Package can not be used in custom code deployment Main : in source Main". If I make .jar using

jar cf App42ServerPN.jar *

I get the message "Internal Server Error". What I'm doing wrong?

P.S. Also I can't increment the badge using java code. Becouse "Send Custom Push Message To User In Key Value Or JSON Format" option is unavailable in java. Is there any way to push notification from Custom code and increase badge counter on the iOS devices?

Thank you in advance.

P.P.S. I get Error in both cases. Using AppHQ I get this:

When I run the deploy code from Eclipse, I get this message:

Exception in thread "main" {"app42Fault":{"httpErrorCode":500,"appErrorCode":1500,"message":"Internal Server Error","details":"Internal Server Error. Please try again"}}



at Main.main(

Thank you for response!

asked Feb 18, 2016 in Java by bilal (16 points)
edited Feb 18, 2016 by bilal

Could you please share your app name and jar with us? If possible then please share your project source code with us at It will help us to provide better support to you.

Himanshu Sharma

1 Answer

+1 vote
Best answer

Hi Bilal,


Could you please let me know when you are getting Internal Server Error? Is this exception occurred at the time of deploying your jar file on App42 database using AppHQ Management Console or  while running your custom code through API. If possible then please share complete logs and screenshots. It will help us to provide better support to you.


P.S You can send message as a JSON String in sendPushMessageToUser function like {"alert":"Get free BribeMe, extra points or double time for bonuses!","badge":"2"}.



Himanshu Sharma

answered Feb 18, 2016 by hs00105 (2,005 points)
selected Mar 22, 2016 by bilal
Thanks for sharing the code with us. It seems like you have missed the steps of writing server-side custom code. Please have a look at this tutorial ( and the sample which comes along with this tutorial. If you still require any help from my side then let me know. I will be happy to help.  

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