CodeRunner NoClassDefFoundError

Hi,

Running CodeRunner on Mac OSX JDK 1.8 gives me the following error:

Listening for transport dt_socket at address: 5005

[INFO] CodeRunner™ Backendless Debugging Utility

[INFO] Copyright© 2015 Backendless Corp. All rights reserved.

[INFO] Version: 2.1 Build date: 20150728-1412

[INFO] Registering runner on: https://api.backendless.com with secretKey: (removed)

[INFO] Runner successfully registered

[INFO] Parsing event model…

Exception in thread “Thread-9” java.lang.NoClassDefFoundError: backendless/com/backendless/AbstractDataPermission (wrong name: com/backendless/AbstractDataPermission)

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:760)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)

at java.net.URLClassLoader.access$100(URLClassLoader.java:73)

at java.net.URLClassLoader$1.run(URLClassLoader.java:368)

at java.net.URLClassLoader$1.run(URLClassLoader.java:362)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:361)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

at com.backendless.coderunner.util.ReflectionUtil$1.visitFile(ReflectionUtil.java:58)

at com.backendless.coderunner.util.ReflectionUtil$1.visitFile(ReflectionUtil.java:46)

at java.nio.file.Files.walkFileTree(Files.java:2670)

at java.nio.file.Files.walkFileTree(Files.java:2742)

at com.backendless.coderunner.util.ReflectionUtil.getSubTypesOf(ReflectionUtil.java:45)

at com.backendless.coderunner.parser.EventModelParser.parseDebugModel(EventModelParser.java:99)

at com.backendless.coderunner.InstructionsFetcher.executeCommandSafe(InstructionsFetcher.java:65)

at com.backendless.coderunner.InstructionsFetcher.run(InstructionsFetcher.java:32)

My server code contains one model and one timer.

Thanks

Hello,

where did you get coderunner from code generation or download from site?

Hello!

Can you tell me if you have handlers for any event, or you have only one timer?
Also what is your model for? Do you use it in the timer event handler?

best regards,
Alex Navara

I got the code (zip file) from code generation after adding a database table and an empty trigger. Do I need the SDK as well to develop server code? If so, which one?

(comment moved to reply)

I have one data table which I plan to fill in the timer using external data from a web request. I combined the following two blog posts into an otherwise empty new app:

  1. http://support.backendless.com/knowledge-base/article/custom-business-logic-mbaas-server-code-get-start-short-guide
  2. http://support.backendless.com/knowledge-base/article/creating-custom-business-logic-timer-with-console

So, your timer event handler looks something like ( assuming that your table is named RequestInfo ):

  1. Make some request
  2. Create object of RequestInfo class
  3. Save this object Backendless.Data.of( RequestInfo.class ).save( requestInfo );
    Have I got your idea?
    Also, if it’s possible, it would be very helpful to know what properties does table RequestInfo contain and if you’ve set any permissions for it.
    Thank you!

I changed my save action (your step 3) from
Backendless.Data.save(earthquake)
into
Backendless.Data.of(Earthquake.class).save(earthquake);

And the error went away.

I was not aware that these errors could be caused by bugs in my code. I was under the impression that it would only deploy to the server and possibly crash during runtime when the timer is started. Thanks for clearing this up.

I now get this error when running CodeRunner:

[ERROR] Runner registration failed. Please check ‘application.id’, ‘application.secretKey’ and ‘application.version’ in ‘runner.properties’ file.

[ERROR] Unfortunately, Debugging Utility disconnected unsuccessfully

What could cause this?

The only reason for this error is that your runner.properties file contains incorrect keys. This file is located in “bin” folder. Compare keys from this file and keys from your app. application.secretkey is CodeRunner secret key.
Do they match?

No, the SDK is bundled into the project/libs you downloaded. I assume you did not add any jars to the /libs folder. We will try reproducing the problem on our end and report back.

Yes they match, it is the same key I paste at the command line as the argument to CodeRunner.sh. I copied it from the web console App Settings -> Code Runner Secret Key. Is that the correct one?

This is the runner.properties file content (with my key crossed out) :

This is main configuration file for Code Runner

Application id

application.id = deploy

Code Runner ID assigned by Backendless Console.

application.secretKey = XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

Application version name

Default: v1

application.version = v1

Optional argument. Search path for classes which will be used for debugging or publishing.

By default Code Runner looks for the ./build/classes directory located in the current directory

location.classes = …/classes/

Optional argument. Search path for jar files which are the dependencies for the code which is debugged or published.

By default Code Runner looks for the ./build/libs directory located in the current directory.

location.jar = …/libs/

System properties

Don’t touch, if you do not really understand this

system.server.url = https://api.backendless.com

system.redis.master.host = cl.backendless.com

system.redis.master.port = 6379

system.pool.core = 20

system.type = LOCAL

system.repo.path = …/repo/

enterprise.allowedHosts = api.backendless.com,\

api.backendless.com,\

localhost,\

localhost:9000,\

api.gmo-mbaas.com, \

            gmo-mbaas.com

Looks like the problem is in this line:

application.id = deploy

Rather than “deploy”, it should contain your application id from the Manage > App Settings screen in backendless console.

I also thought that property should have the real app id. I edited the runner.properties file and now I’m back at my original problem, the

java.lang.NoClassDefFoundError exception came back. Running in circles here.

The CodeRunner process seems to keep running despite the exception, but nothing shows in the Debug tab in the web console.

We cannot reproduce the problem. Would you be able to zip up everything and share it with us? I can prepare a shared dropbox folder for you if you’d like.

yes that would be great

Done, you should see an invite in your email.

Thanks, I’ve uploaded an archive of the sources

I’ve reproduced this issue. The reason is that your libs folder contains unpacked backendless.jar. This folder should contain only the backendless.jar. Remove all other files from this folder and try again.

Also I’d like to notify you that there is a small bug which would not allow you to execute timer event handler properly. To avoid it use workaround: change https:// to http:// in Bootstrap class, method onStart(), line 15 of your code.

Yes, that was the problem! I had unpacked it before to try analyse the errors I got. Sorry for that.

My other error has probably been fixed by the https -> http change, I got my test record inserted on the server.

Thanks for your support!