Event does not fire

I posted this issue also on SO: http://stackoverflow.com/questions/36022179/backendless-event-does-not-fire
but I think it should actually be rather here.
I have points and they have a number. Since my app works offline and other users can create points, I need a way to set a unique number for each point.
So I use a beforeCreate event to get the highest point number and set the new point to the next number.
But the event does not get fired. I tried a simple test where I set a field to “ABC” but that never happens and debugging it also never triggered the event.
What am I doing wrong?

Hi Jurgen,

Could you please demonstrate the problem with some sample code (hopefully something brief and to the point).

Regards,
Mark

I tried the new lib but there is no difference. Is it ok to include it in my app as 3.0.8.2?

When syncing I do

newPoint.save();

and when I look it up in Backendless the Point was not modified according to the event I defined. The event is defined as

@Asset( "Point" ) 
public class PointTableEventHandler extends com.backendless.servercode.extension.PersistenceExtender<Point>
{ 
 @Override
 public void beforeCreate( RunnerContext context, Point point) throws Exception
 {
 System.out.println("enter beforeCreate");
 point.setPhoneNumber("12345");
 System.out.println("exit beforeCreate");
 } 
}

Is it a problem that I defined my Point class as derived from my own class called BackendlessObject that includes the default fields like created, updated, objectId and ownerId?

I use Android Studio 2.1 with JDK1.8

I have a few questions for you:

    Do you run CodeRunner in the debug mode (locally) or deployed the event handler to production?
    Does the event handler show up in the Debug or Production tabs on the Business Logic screen?
Mark

I tried both - first using “deploy.bat” to deploy the handler. It shows up in the production tab.

And also debugging with “CodeRunner.bat” but there is no console output from the event nor does Eclipse stop at the breakpoint. I configured Eclipse on port 5005.

Thanks for the answers. Since you’re calling the API from a timer, it requires an updated CodeRunner (the one with the fixed SDK for Android/Java). We’re working on rolling out an update which should be available this week. A temporary workaround would be to use the REST API or you’d need to wait just a bit until the updated CodeRunner is available.

Regards,
Mark

When you mean by “calling the API from a timer” that I run the newPoint.Save() from an AsyncTask, then yes, thats true.

I guess I wait until the update comes out. This week would be really great.

Thanks.

Juergen,

I apologize, I got this mixed up with another support topic…

I assume you call “newPoint.Save()” from an Android app, is that correct? If so, have you replaced backendless library in that app with the one from github?

Regards,
Mark

Yes, Android with Android Studio 2.1. And yes I replaced the lib with the new one from GitHub everywhere I use it.

With the updated backendless.jar, before/AfterCreate event handlers will fire when the persisted object does not have a value in objectId. Is this the case in your app?

Yes, the objectId and even created and updated are NULL. I use the new lib. But still it does not fire.

Could you also try creating a new object using REST Console? It is available on the Data screen - click the REST Console tab. You will need to put a JSON representation of the object you create.

Tried it. It works. The event is fired and the test field filled.

Is there any possibility the jar is not updated in the project? Could you possibly be using the jar from maven and not the updated jar from the libs folder?

Could you show your build.gradle file?

I see there is a backendless-3.0.8.2_324131376629ec873c8edcc8b2078ea804135cac.jar in my build folder that has only 386kB instead of 934kB.

My build.gradle (reduced):

apply plugin: 'com.android.application'

android {
 compileSdkVersion 23
 buildToolsVersion "23.0.2"

 defaultConfig {
 applicationId "com.doubrawa.territories"
 minSdkVersion 16
 targetSdkVersion 23
 }
 buildTypes {
 release {
 minifyEnabled false
 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
 }
 }
}

dependencies {
 compile fileTree(include: ['*.jar'], dir: 'libs')
 testCompile 'junit:junit:4.12'
 compile fileTree(include: ['dtp_library'], dir: 'libs')
 compile project(':libs:dtp_library')
 compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
 compile 'com.backendless:backendless:3.0.8.2'
 compile 'com.android.support:appcompat-v7:23.1.1'
 compile 'com.android.support:design:23.1.1'
 compile 'com.android.support:support-v4:23.1.1' 
}

I changed the dependency in my gradle file to

compile 'com.backendless:backendless:+'

Now the backendless-3.0.8.2_324131376629ec873c8edcc8b2078ea804135cac.jar disapeared but the event still does not fire.

The following line must be removed from your build file - it imports the library that does not have the change:

compile 'com.backendless:backendless:3.0.8.2'

Now it works! I replaced that line in the gradle with

compile files('D:/someFolders/TerritoriesMobile/libs/backendless.jar')

Awesome. Thank you very much for your help and fast responses.