Custom Business Logic / CodeRunner update problem

Hi! Since the last update on February 22nd my Custom Business Logic stopped working so I recompiled it with the latest release (downloaded from console) and now I can´t publish or debug it with CodeRunner, here is the error I´m getting.

Thank you

OS Windows 10
Java Version 1.8.0_51
Coderunner version 3.0.8.2

Deploy.bat
Starting CodeRunner
Listening for transport dt_socket at address: 5005
[INFO] CodeRunner™ Backendless Debugging Utility
[INFO] Copyright© 2016 Backendless Corp. All rights reserved.
[INFO] Version: 3.0.8.2 Build date: 20160223-1203
[INFO] CodeRunner session is running for 2 hour and will be terminated on 20:41:47.972[UTC]

[INFO] Registering runner on: https://api.backendless.com with secretKey: 043A27FA-70CD-8BCF-FFF5-387B87608E00
[INFO] Runner successfully registered
[INFO] Parsing event model…
[ERROR] Cannot run program “jar” (in directory “…\classes”): CreateProcess error=2, The system cannot find the file specified
[INFO] Debugging Utility disconnected successfully
[INFO] Thank you for using Backendless

CodeRunner.bat
Starting CodeRunner
Listening for transport dt_socket at address: 5005
[INFO] CodeRunner™ Backendless Debugging Utility
[INFO] Copyright© 2016 Backendless Corp. All rights reserved.
[INFO] Version: 3.0.8.2 Build date: 20160223-1203
[INFO] CodeRunner session is running for 2 hour and will be terminated on 20:42:40.457[UTC]

[INFO] Registering runner on: https://api.backendless.com with secretKey: 043A27FA-70CD-8BCF-FFF5-387B87608E00
[INFO] Runner successfully registered
[INFO] Parsing event model…
java.security.AccessControlException: access denied (“java.io.FilePermission” “file:\C:\Users\FABIO\Downloads\Jkb-25\bin\CodeRunner.jar!\weborb-config.xml” “read”)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at com.backendless.coderunner.runtime.security.CodeRunnerSecurityManager.checkPermission(CodeRunnerSecurityManager.java:52)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.File.exists(Unknown Source)
at weborb.util.watcher.FileWatcher.<init>(FileWatcher.java:16)
at weborb.config.LocalConfig.getWatcher(LocalConfig.java:28)
at weborb.config.ORBServerConfig.init(ORBServerConfig.java:203)
at weborb.config.ORBServerConfig.<init>(ORBServerConfig.java:106)
at weborb.config.ORBServerConfig.getORBConfig(ORBServerConfig.java:255)
at weborb.config.ORBServerConfig.getORBConfig(ORBServerConfig.java:270)
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 weborb.config.ORBConfig.getORBConfig(ORBConfig.java:58)
at weborb.types.Types.addClientClassMapping(Types.java:129)
at com.backendless.UserService.<init>(UserService.java:56)
at com.backendless.UserService.<clinit>(UserService.java:47)
at com.backendless.Backendless.<clinit>(Backendless.java:42)
at com.backendless.jkb.Bootstrap.onStart(Bootstrap.java:16)
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.util.ReflectionUtil$2.runImpl(ReflectionUtil.java:105)
at com.backendless.coderunner.runtime.concurrent.ExtendedRunnable.run(ExtendedRunnable.java:22)
at java.lang.Thread.run(Unknown Source)
[WEBORB ERROR, Thread-26, 02:27:16 06:42:47] Error initializing WebORB configuration
java.lang.RuntimeException: access denied (“java.io.FilePermission” “file:\C:\Users\FABIO\Downloads\Jkb-25\bin\CodeRunner.jar!\weborb-config.xml” “read”)
at weborb.config.ORBServerConfig.<init>(ORBServerConfig.java:111)
at weborb.config.ORBServerConfig.getORBConfig(ORBServerConfig.java:255)
at weborb.config.ORBServerConfig.getORBConfig(ORBServerConfig.java:270)
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 weborb.config.ORBConfig.getORBConfig(ORBConfig.java:58)
at weborb.types.Types.addClientClassMapping(Types.java:129)
at com.backendless.UserService.<init>(UserService.java:56)
at com.backendless.UserService.<clinit>(UserService.java:47)
at com.backendless.Backendless.<clinit>(Backendless.java:42)
at com.backendless.jkb.Bootstrap.onStart(Bootstrap.java:16)
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.util.ReflectionUtil$2.runImpl(ReflectionUtil.java:105)
at com.backendless.coderunner.runtime.concurrent.ExtendedRunnable.run(ExtendedRunnable.java:22)
at java.lang.Thread.run(Unknown Source)

[WEBORB ERROR, Thread-26, 02:27:16 06:42:47] Error initializing WebORB configuration
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 weborb.config.ORBConfig.getORBConfig(ORBConfig.java:58)
at weborb.types.Types.addClientClassMapping(Types.java:129)
at com.backendless.UserService.<init>(UserService.java:56)
at com.backendless.UserService.<clinit>(UserService.java:47)
at com.backendless.Backendless.<clinit>(Backendless.java:42)
at com.backendless.jkb.Bootstrap.onStart(Bootstrap.java:16)
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.util.ReflectionUtil$2.runImpl(ReflectionUtil.java:105)
at com.backendless.coderunner.runtime.concurrent.ExtendedRunnable.run(ExtendedRunnable.java:22)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at weborb.config.ORBServerConfig.checkConfigModifications(ORBServerConfig.java:332)
at weborb.config.ORBServerConfig.getORBConfig(ORBServerConfig.java:264)
at weborb.config.ORBServerConfig.getORBConfig(ORBServerConfig.java:270)
… 17 more

[ERROR] Cannot run program “jar” (in directory “…\classes”): CreateProcess error=2, The system cannot find the file specified
[INFO] Debugging Utility disconnected successfully
[INFO] Thank you for using Backendless
Press any key to continue . . .

There is a known problem with CodeRunner on Windows. We’re working on it, should be fixed soon.

I could get it deployed and debugged on linux but my code´s still being ignored/ bypassed.
This is happening since the last update.

Thank you for any help.

Please let us know your APP ID.

Thanks,
Mark

It´s 851BD18F-1545-9ADF-FF99-9D1A3EF8A500

Thanks

Thanks. Could you show what event handlers you deploy and what API you invoke (which should trigger the event handlers)?

Hi, I´m calling the afterCreate Event handler for “Plays” Data Table, here is the code
for PlaysTableEventHandler.java

I tried throwing some exception but coderunner still didn´t catch it.

package com.backendless.jkb.events.persistence_service;

import com.backendless.Backendless;
import com.backendless.BackendlessCollection;
import com.backendless.BackendlessUser;
import com.backendless.geo.BackendlessGeoQuery;
import com.backendless.geo.GeoPoint;
import com.backendless.geo.Units;
import com.backendless.persistence.BackendlessDataQuery;
import com.backendless.property.ObjectProperty;
import com.backendless.servercode.ExecutionResult;
import com.backendless.servercode.RunnerContext;
import com.backendless.servercode.annotation.Asset;
import com.backendless.servercode.annotation.Async;

import com.backendless.jkb.models.Jukebox;
import com.backendless.jkb.models.Plays;
import com.backendless.messaging.DeliveryOptions;
import com.backendless.messaging.PublishOptions;
import java.util.Date;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;

/**

  • PlaysTableEventHandler handles events for all entities. This is accomplished
  • with the @Asset( “Plays” ) annotation.
  • The methods in the class correspond to the events selected in Backendless
  • Console.
    */

@Asset( “Plays” )
public class PlaysTableEventHandler extends com.backendless.servercode.extension.PersistenceExtender<Plays>
{

@Async
@Override
public void afterCreate( RunnerContext context, Plays plays, ExecutionResult<Plays> result ) throws Exception
{
BackendlessUser user = Backendless.UserService.findById(String.valueOf(plays.getUsuario()));
Jukebox box = Backendless.Persistence.of(Jukebox.class).findById(plays.getJukebox().getObjectId());
Integer saldo = (int) user.getProperty(“creditos”);
String channel = “JUKEBOX” + plays.getJukebox().getObjectId().split("-")[0];
//
if (saldo > 0) {
if (box.getLocal() != null) {
if (user.getProperty(“local”) != null) {
if (verificaDistanciaUserJukebox(box, (GeoPoint) user.getProperty(“local”))) {
user.setProperty(“creditos”, saldo - 1);
Backendless.UserService.update(user);
plays.setStatus(“OK_EM_FILA”);
sendNewSongMsg(channel, user);
} else {
plays.setStatus(“ERRO_LOCATION”);
}
} else {
plays.setStatus(“ERRO_USER_LOCATION”);
}
} else {
plays.setStatus(“ERRO_BOX_LOCATION”);
}
} else {
plays.setStatus(“ERRO_SALDO”);
}
try {
Backendless.Persistence.save(plays);
} catch (Exception e) {
}
}
public void sendNewSongMsg(String channel, BackendlessUser user) {
PublishOptions publishOptions = new PublishOptions();
publishOptions.setSubtopic(“newsong”);
publishOptions.putHeader(“user-token”, user.getObjectId());
publishOptions.putHeader(“BL_PUBLISHER_ID”, user.getObjectId());

    DeliveryOptions deliveryOptions = new DeliveryOptions();
    Date publishDate = new Date(System.currentTimeMillis() + 2000); // add 5 seconds
    
    deliveryOptions.setPublishAt(publishDate);

    Backendless.Messaging.publish(channel, "New Song Added", publishOptions, deliveryOptions);
}
private boolean verificaDistanciaUserJukebox(Jukebox box, GeoPoint userlocation) {
    boolean result = true;
    BackendlessGeoQuery geoQuery = new BackendlessGeoQuery();
    geoQuery.setLatitude(box.getLocal().getLatitude());
    geoQuery.setLongitude(box.getLocal().getLongitude());
    geoQuery.addCategory("userlocation");
    geoQuery.setIncludeMeta(false);
    geoQuery.setRadius(100d);
    geoQuery.setUnits(Units.METERS);
    BackendlessCollection&lt;GeoPoint&gt; geoPointCollection = Backendless.Geo.getPoints(geoQuery);
    Iterator&lt;GeoPoint&gt; iterator = geoPointCollection.getCurrentPage().iterator();
    while (iterator.hasNext()) {
        GeoPoint geoPoint = iterator.next();

// System.out.println(“geopoint:” + geoPoint.getLongitude() + “|” + geoPoint.getLatitude());
if (Objects.equals(geoPoint.getLatitude(), userlocation.getLatitude()) && Objects.equals(geoPoint.getLongitude(), userlocation.getLongitude())) {
result = true;
break;
}

    }

    return result;
}

}

Sorry, the API is javascript

I didn’t understand what “sendNewSongMsg” method has to do with the event handler.

Also, I’d like to see the client-side code which you believe should trigger the event handler.

I am having similar while trying to override “Before Create” event handler for custom model. Whatever logs or exception I put in code, the Coderunner doesn’t show any logs or exception in debug mode. From the docs it looks like an easy things to do, but somehow it is not working. Coderunner is successfully deploying the handlers in both Debug and Production mode but the handlers are not showing any SystemLogs such as System.out.println .

The sendNewSongMsg method sends a message so devices connected on the specified channel will get notified,
here is the javascript function, it´s working fine, but the event handler should do some validation and change the “Plays” object status.

function gravaPlay(args) {
try {
var play = new Classes.Plays(args);
delete play.jukebox._private_relations;
delete play.jukebox._private_geoRelations;
delete play.jukebox._private_dates;
play.save(new Backendless.Async(function (data) {
window.location = “#/confirma/”;
}, function (e) {
window.location = “#/err/”;
}));
}
catch (e) {
showInfo(e.message);
}
}

@Fabio check this http://support.backendless.com/t/backendless-business-logic-not-call

Thank you Harsh it seems to be the same problem, as Mark said the fix will be published on the next update.
Still coudn´t find the create method on JS API.

The handler worked for a while today but stopped.

I´ve downloaded and updated my code to 3.0.10 and my Event Handlers are still
being ignored by backendless. Do I have to update the javascript API too?

Fabio,

What event handlers do you implement?

Regards,
Mark

Hi Mark!
I implemented AfterCreate and AfterUpdate on PlaysTableEventHandler.

Thanks

Do the event handlers show up in the Debug tab of the Business Logic screen?

Yes, on Debug and Production

What does your code for the Update operation look like?

Could you please post here complete output from CodeRunner?

Could you also try it from REST console and see if the event handler is triggered? You can read more about REST Console here (it talks about GET, but you can use it for PUT and POST requests):
https://backendless.com/feature-77-using-backendless-rest-console-to-fetch-your-data/