The problem with variable initialization of App42 Custom Code (Java)

0 votes

Hi.

Do you can not use an anonymous classes and instance initializer when initializing variables in App42 custom code? The following code works fine on the local host, but, Application Exception occurs when you run on App42. 

public static Map [] get () {

    Map [] data = new HashMap [] {
        new HashMap<String,String> () {{
            put ("foo", "fooVal1"); 
            put ("bar", "barVal1"); 
        }}, 
        new HashMap<String,String> () {{
            put ("foo", "fooVal2"); 
            put ("bar", "barVal2"); 
        }} 
    }; 
    return data; 
 }
closed with the note: Closing this thread as there was no update from last 2 Weeks or more. Please raise a new query if problem persists.
asked Jul 1, 2014 in App42 Cloud API-BaaS by appwarp (20 points)
closed Sep 16, 2014 by sushil
what is the exception message you are getting? Is it a deploy time exception or run time exception?
It is a run time exception.
The exception message is as follows.

Exception in thread "main" com.shephertz.app42.paas.sdk.java.App42BadParameterException: {"app42Fault":{"httpErrorCode":400,"appErrorCode":1903,"message":"Bad Request","details":" Application Exception "}}
    at com.shephertz.app42.paas.sdk.java.connection.RESTConnectorAsync.handleException(RESTConnectorAsync.java:298)
    at com.shephertz.app42.paas.sdk.java.connection.RESTConnectorAsync.executeCustomCode(RESTConnectorAsync.java:266)
    at com.shephertz.app42.paas.sdk.java.customcode.CustomCodeService.runJavaCode(CustomCodeService.java:216)
    at com.myapp.helper.AntHelper.run(AntHelper.java:64)
    at com.myapp.helper.AntHelper.main(AntHelper.java:32)
Java Result: 1

It will work fine when you run locally.
Java Runtime Environment of the local is as follows.

java version "1.6.0_65"
Java (TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot (TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
It means it is coming because application code has some issue. It is not because of any usage constraints. We will replicate it and update you on this.
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
...