Custom Event User objectId Error

Am debugging a custom event logic using CodeRunner and getting the error

SEVERE: null
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:498)
 at com.backendless.coderunner.runtime.task.EventInvocationTask.runImpl(EventInvocationTask.java:111)
 at com.backendless.coderunner.runtime.executor.ExtendedRunnable.run(ExtendedRunnable.java:39)
 at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
 at com.backendless.servercode.InvocationContext.getUserId(InvocationContext.java:75)
 at com.pendo.events.custom_events.BlissfulEventHandler.handleEvent(BlissfulEventHandler.java:27)
 ... 7 more

In the Custom event, am first trying to get the objectId of the logged in user like so

@Override
 public Map handleEvent( RunnerContext context, Map eventArgs )
 {
 // add your code here
 String parentObjectId = com.backendless.servercode.InvocationContext.getUserId();
......}

What could i be missing?

Regards,
George

Hello,

Instead of “com.backendless.servercoce.InvocationContext”, use the “context” object passed into the handleEvent method.

Regards,
Mark

Like so

@Override
public Map handleEvent( RunnerContext context, Map eventArgs )
{
// add your code here
String parentObjectId = context.getUserId();
......}

Further to this, how do i get the

... 7 more

errors as shown in cmd on running CodeRunner.bat?

Regards,
George

Yes, like that.

You could attach a debugger to the process and inspect the exception in the debugger. See the docs for more info:
https://backendless.com/docs/bl-java/doc.html#attaching-ide-debugger

Mark

Hello Mark,

Using the “context” object passed into the handleEvent is working, at least eliminates the original problem, thanks.

But I am now getting the error “Custom business logic execution has been terminated because it did not complete in permitted time - 7200 seconds” with my server side custom event.
7200 seconds is equivalent to 2 hrs yet the error is being returned after just a few seconds.
It executed once though and has now permanently reverted to this.
I have gone as far as simplifying the logic being executed in the custom event to return just a few table counts and am still getting the same errror.
CodeRunner does not move beyond “Waiting for events…”
Regards,
George

Hi George,

I see you opened another topic for the other problem. Please use that thread for discussing it.

I will mark this one as “Solved”.

Regards,
Mark