What does AppErrorCode 2103 means on a Scheduled job?

0 votes
Hi, Im getting this error code on the ScheduleLogs when i try to excecute my custom code as a scheduled job. If I try the same code as a local program everything works just fine.

 

My code try to get a DocumentById, read a value from it and then update it.

 

{"app42Fault":{"httpErrorCode":404,"appErrorCode":2103,"message":"Not Found","details":"The file with the name GetDocByIdNewVersion does not exist."}}

 Btw, I dont have any funtion or class or file with the name "GetDocByIdNewVersion". Could it be something on the build?

Thanks in Advance.
asked Aug 11, 2014 in App42PaaS & BPaaS by chrystiansilva (33 points)
This exception comes up if you are trying to fetch a file with the name which does not exist in Upload Service. This looks like a problem related to your code and not with scheduling service. Can you run your deployed custom code using runJava method call from client SDK using Custom code service?
Hi,

Yes I've tried to run the custom code using runJava method on my client SDK and everything is working just fine, actually on more test I've upload the same custom code with different names and try to schedule it, everytime it throws me a different non existent file name as an error, most of the names were some custom codes I've tried before, and that they are no longer deployed, so I belive it may be something in the DB.
This looks strange. Can you put your custom code snippet for review?
Sure, here it is:

public class MyCustomCode implements Executor
{
    private ServiceAPI sp = new ServiceAPI(         
                 "9bh5a57f8g1c7d6356cfbdf2f8eb8efs15bdb651b8ddd5a285d4d88",
                  "0ese86ab65daf09e219ef323e3aafe6b09710d88467df7f66a8a31");   
      
    private final int HTTP_STATUS_SUCCESS = 200;
    private String moduleName = "App42ScheduledCodeTest";

    /**
     * Write your custom code inside this method
     */
    @Override
    public HttpResponseObject execute(HttpRequestObject request)
    {
        JSONObject body = request.getBody();
        // Create JSON Response Based on Your business logic
        JSONObject jsonResponse = new JSONObject();
               
        //Build Log Service For logging in Your Code
        LogService logger = sp.buildLogService();
        logger.debug(" Recieved Request Body : " + body.toString(), moduleName);

        // Write Your Custom Code Here
        StorageService storageService = sp.buildStorageService();
       
        String dbName = "FRAKTALIADB";  
        String collectionName = "WeekInfo";
        String Key = "CurrentWeek_N12";
        String docID = "53e90ef0e4b0cf84a5227900";  //N12
        int week = 0;
        logger.debug("Find Document with ID in ["+dbName+"]["+collectionName+"] ID ["+docID+"] NOW!", moduleName);
        try
        {
            Storage storage = storageService.findDocumentById(dbName,collectionName,docID);
            logger.debug("dbName is " + storage.getDbName(), moduleName);  
            logger.debug("collection Name is " + storage.getCollectionName(), moduleName);
            ArrayList<Storage.JSONDocument> jsonDocList = storage.getJsonDocList();
            logger.debug("documents founded ["+jsonDocList.size()+"]" , moduleName);
            for(int i=0;i<jsonDocList.size();i++)  
            {  
                logger.debug("objectId is " + jsonDocList.get(i).getDocId(), moduleName);    
                logger.debug("Jsondoc is " + jsonDocList.get(i).getJsonDoc(), moduleName);
                try
                {
                    JSONObject document = new JSONObject(jsonDocList.get(i).getJsonDoc());
                    week = document.optInt(Key,0);
                    logger.debug(Key+" in document is " + week, moduleName);
                    week++;
                    //update new week value in DB
                    String docId = jsonDocList.get(i).getDocId();    
                    JSONObject newJsonObject = new JSONObject();
                    try
                    {
                        newJsonObject.put(Key,week);
                    }
                    catch (JSONException e1)
                    {
                        // Do exception Handling for JSON Parsing
                    }
                    Storage updatedStorage = storageService.updateDocumentByDocId(dbName, collectionName, docId, newJsonObject);    
                    ArrayList<Storage.JSONDocument> updatedJsonDocList = updatedStorage.getJsonDocList();              
                    for(int j=0;j<updatedJsonDocList.size();j++)  
                    {  
                    //    logger.debug("UpdatedObjectId is " + updatedJsonDocList.get(j).getDocId(), moduleName);    
                    //    logger.debug("UpdatedCreatedAt is " + updatedJsonDocList.get(j).getCreatedAt(), moduleName);   
                        logger.debug("UpdatedAt is " + updatedJsonDocList.get(j).getUpdatedAt(), moduleName);    
                        logger.debug("UpdatedJsondoc is " + updatedJsonDocList.get(j).getJsonDoc(), moduleName);
                    }
                    try
                    {
                        jsonResponse.put("status", "success");
                    }
                    catch (JSONException e2)
                    {
                        // Do exception Handling for JSON Parsing
                    }
                    break;
                }
                catch(JSONException e3)
                {
                    logger.debug("Cant create document from ["+jsonDocList.get(i).getJsonDoc()+"]", moduleName);
                    try
                    {
                        jsonResponse.put("status", "failed");
                    } catch (JSONException e) {
                        // Do exception Handling for JSON Parsing
                    }
                }
            }
        }
        catch(App42Exception exception)   
        {  
            exception.printStackTrace();
            int appErrorCode = exception.getAppErrorCode();  
            int httpErrorCode = exception.getHttpErrorCode();
            logger.debug("Error finding documents. appCode["+appErrorCode+"] httpCode["+httpErrorCode+"]  Message["+exception.getMessage()+"]", moduleName);
            //logger.debug("Cant find document with id ["+docID+"]", moduleName);
            for(int i = 0; i < exception.getStackTrace().length; i++)
            {
                logger.debug("StackTrace element["+i+"] = ["+exception.getStackTrace()[i].toString()+"]", moduleName);
            }
            
            try
            {
                jsonResponse.put("status", "failed");
            } catch (JSONException e4) {
                // Do exception Handling for JSON Parsing
            }
            
        }
         
       
        logger.info("Running Scheduled Custom Code", moduleName);
        try {
            jsonResponse.put("message", week);
           
        } catch (JSONException e5) {
            // Do exception Handling for JSON Parsing
        }
        // Return JSON Response and Status Code
        return new HttpResponseObject(HTTP_STATUS_SUCCESS, jsonResponse);
    }
Exception that you have got  belongs to File Upload service and strangely you don't have any call for it in your code.

Requesting to change your API Key/Secret Key first as you have posted it in public forum and pass me your app name and custom code name at ajay.tiwari@shephertz.com. We have to have a look at backend logs.

1 Answer

0 votes
Hi Chrystiansilva,

We looked into this issue and found out this problem comes up if you try to run undeployed custom code.

Please make sure that your scheduled custom code is not undeployed after scheduling it. If you undeploy it make sure you also cancel the scheduling.

We will also add this in our AppHQ console so that undeployed custom code can cancel all scheduled jobs along with it to avoid any confusion.

Let me know if it helps.

Thanks
answered Aug 13, 2014 by hs00105 (2,005 points)
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