I got the following error when I tried to initialize Braintree into my custom logic code:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.backendless.coderunner.runtime.task.EventInvocationTask.runImpl(EventInvocationTask.java:97)
at com.backendless.coderunner.runtime.concurrent.ExtendedRunnable.run(ExtendedRunnable.java:22)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ExceptionInInitializerError
at com.backendless.pack_app.events.custom_events.RequestTokenEventHandler.handleEvent(RequestTokenEventHandler.java:61)
… 7 more
Caused by: java.security.AccessControlException: access denied (“java.lang.RuntimePermission” “getenv.*”)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
at java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.backendless.coderunner.runtime.security.CodeRunnerSecurityManager.checkPermission(CodeRunnerSecurityManager.java:67)
at java.lang.System.getenv(System.java:944)
at com.braintreegateway.Environment.developmentBaseURL(Environment.java:32)
at com.braintreegateway.Environment.<clinit>(Environment.java:10)
… 8 more
This is my code:
@Override
public Map handleEvent( RunnerContext context, Map eventArgs )
{
Map<String, String> map = new HashMap<String, String>();
BraintreeGateway gateway = new BraintreeGateway(Environment.SANDBOX, MERCHANT_ID, PUBLIC_KEY, PRIVATE_KEY);
map.put(KEY_TOKEN, gateway.clientToken().generate());
return map;
}