Backendless.UserService.findById() triggers exception within CustomEventHandler

Hi,
I’ve recently resumed development of my server code after a few weeks off it. During that time a new version of the CodeRunner (amongst other things) has been released. Not sure if that’s related to my issue but code that was previously working fine isn’t working any more. Specifically, calls to:

Backendless.UserService.findById( String p_userID )

When calling this method via a CustomEventHandler it triggers the following exception.


SEVERE: com.backendless.BackendlessUser cannot be cast to java.util.HashMap
java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at com.backendless.coderunner.runtime.task.EventInvocationTask.runImpl(E
ventInvocationTask.java:97)
 at com.backendless.coderunner.runtime.concurrent.ExtendedRunnable.run(Ex
tendedRunnable.java:22)
 at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: com.backendless.BackendlessUser cannot
be cast to java.util.HashMap
 at com.backendless.UserService.findById(UserService.java:533)

This happens in all places I make this call, and isn’t related to the assignment of the method result to the wrong variable type. In other words, I don’t attempt to assign or cast the result to a java.util.HashMap.
Any reason why this might happen? It was happening whilst I was using the previous version of the CodeRunner, so I updated my setup to version 2.0, however the problem persists.
There’s also another exception triggered when I start the CodeRunner, however i’m not sure if that’s directly related to this issue, so i’ll post another topic for that. Without delving into the detail, that triggers this…

C:\Users\<username>\Desktop\CodeRunnerSDK_2.0\bin>CodeRunner.bat
Starting CodeRunner
Listening for transport dt_socket at address: 5005
[INFO] CodeRunner(tm) Backendless Debugging Utility
[INFO] Copyright(C) 2015 Backendless Corp. All rights reserved.
[INFO] Version: 1.15 Build date: 20150610-1505


[INFO] Registering runner on: http://api.backendless.com with secretKey: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX
[INFO] Runner successfully registered
[INFO] Parsing event model...
java.security.AccessControlException: access denied ("java.io.FilePermission" "f
ile:\C:\Users\<username>\Desktop\CodeRunnerSDK_2.0\bin\CodeRunner.jar!\weborb-con
fig.xml" "read")
 at java.security.AccessControlContext.checkPermission(Unknown Source)

Cheers!
Grant.

Dear customer!
We will fix the issue soon.
Please, try use CodeRunner from generated code on Business Logic page (see attached file).

Hi Eugene,

Using the CodeRunning from the generate code fixed the weborb-config.xml issue, confirming that those two issues are unrelated, as the problem with…

Backendless.UserService.findById( String p_userID )

…still remains.

Cheers,
Grant.

Hello Grant.
Please, provide your application-id.

Hi Eugene,

It’s…

A457D875-7D4C-535B-FF1C-200316776800

Many thanks,
Grant.

The issue was fixed.
You can download latest CodeRunner from Business Logic page.
We will update CodeRunner SDK on “Download” page soon.

Please, confirm, that the issue was fixed (with latest CodeRunner),

Best regards,
Eugene.

Hi Eugene,

I downloaded the CodeRunner from the Business Logic page and tried again, however the error persists. Here is the CodeRunner startup message I see:


Starting CodeRunner
Listening for transport dt_socket at address: 5005
[INFO] CodeRunner(tm) Backendless Debugging Utility
[INFO] Copyright(C) 2015 Backendless Corp. All rights reserved.
[INFO] Version: 1.15 Build date: 20150607-1738

I was expecting it to state version ‘2.0’ instead of 1.15, however the build date seems consistent with v2.0. Any ideas?

Cheers.

Strange.
I re-updated CodeRunner on Business Logic page.
Console output should be next:

Starting CodeRunner
Listening for transport dt_socket at address: 5005
[INFO] CodeRunner(tm) Backendless Debugging Utility
[INFO] Copyright(C) 2015 Backendless Corp. All rights reserved.
[INFO] Version: 2.1 Build date: 20150616-1632

Could you check again?

Hi Eugene,

I downloaded again from the Business Logic page and it seems to be using v 2.1 now! :slight_smile: However now none of the breakpoints within my CustomEventHandler(s) are being hit within Eclipse. Eclipse does seem to be connecting to the CodeRunner through it’s debug context though. Within the client these requests are responding with an error, but i’m having trouble ascertaining the error code. This is also the case when hitting standard REST API URLs, i.e. attempting to register devices through the messaging system via:

https://api.backendless.com/v1/messaging/registrations

The response payload doesn’t contain any data, i.e. it is: “” and the response status code is 0. I can’t find any changes to the REST API and i’ve checked to see if all my respective keys are correct, and they seem to be. Is there anything else that could prevent the breakpoints from being hit?

Cheers,
Grant.

Ignore that last reply, i’m an idiot. I was tethering my internet from my phone using USB and it magically switched to WiFi for some reason, which normally wouldn’t be an issue but my landline is bust today! Argh!!! Breakpoints are now being hit :slight_smile:

Cheers!

Unfortunately i’m still receiving the error:


SEVERE: com.backendless.BackendlessUser cannot be cast to java.util.HashMap
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.backendless.coderunner.runtime.task.EventInvocationTask.runImpl(E
ventInvocationTask.java:97)
        at com.backendless.coderunner.runtime.concurrent.ExtendedRunnable.run(Ex
tendedRunnable.java:22)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: com.backendless.BackendlessUser cannot
be cast to java.util.HashMap
        at com.backendless.UserService.findById(UserService.java:533)

So it doesn’t seem to be related to the version of the CodeRunner. Were you seeing this at your end at all?

Cheers,
Grant.

The root of issue located in backendless.jar, which located in “{code_runner_project}/libs/backendless.jar”

If you have attached to coderunner “external” backendless.jar (from android SDK, for example) -> the issue will reproduce.

You should use “generated” ./libs/backendless.jar.

Could this help you?

Bingo, that’s exactly what it was. Thanks so much for your help :slight_smile:

Grant.

Resolved.
If you will have an issue - please contact us to investigate it