Business Logic on Standlone Backendless

Hi!
I would like to know if Business Logic is supposed to work with standalone Backendless?
I’m trying to make something work, but nothing seems to be called.
I successfully upload the compiled java code to my server, but nothing really works, even Timers.
This is the runner.properties (I edited sensible informations like keys and IP of my server)

# This is main configuration file for Code Runner


# Application id
application.id = D58FD012-****-B9C6-****-CD8555A33C00


# Code Runner ID assigned by Backendless Console.
application.secretKey = AE211FA6-****-6A48-****-F48E0D3BE900


# 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 = http://51.*.*.114/api
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,\
51.*.*.114

The Timers and events are visible in the dashboard of the server, under business logic. I can even run the timers and a green popup informs me that it was a success. But nothing is saved in the DB. Here is an example of a timer (Task being a custom table):

public class TestTimerTimer extends TimerExtender
{
 @Override
 public void execute( String appVersionId ) throws Exception
 {
 Task task = new Task();
 task.setTitle("PRETTY PLEASE");
 Backendless.Persistence.of(Task.class).save(task);
 }
}

BeforeCreate, AfterCreate, BeforeRemove, AfterRemove, Timers, absolutely nothing works.
I’m starting to wonder if it can even works or if it’s a limitation of the Standalone Backendless.
Hope you can help me,
Thanks in advance.

Hi Dylan,

Change the following line to use your IP address:

system.redis.master.host = 51...114

Please let me know if it works.

Regards,
Mark

Thanks for your quick reply.
Unfortunately, it doesn’t work. When I try to deploy with my IP as the redis host, it gives me this exception:









[INFO] CodeRunner session is running for 2 hour and will be terminated on 00:07:24.705[UTC]




Exception in thread "main" java.lang.ExceptionInInitializerError

	at com.backendless.coderunner.CodeRunnerLoader.main(CodeRunnerLoader.java:39)

Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

	at redis.clients.util.Pool.getResource(Pool.java:50)

	at redis.clients.jedis.JedisPool.getResource(JedisPool.java:86)

	at com.backendless.redis.JedisManager.getJedis(JedisManager.java:94)

	at com.backendless.redis.JedisManager.execute(JedisManager.java:220)

	at com.backendless.redis.JedisManager.create(JedisManager.java:74)

	at com.backendless.redis.JedisManager.create(JedisManager.java:54)

	at com.backendless.coderunner.redis.RedisPoolManager.<init>(RedisPoolManager.java:62)

	at com.backendless.coderunner.redis.RedisPoolManager.<clinit>(RedisPoolManager.java:19)

	... 1 more

Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused

	at redis.clients.jedis.Connection.connect(Connection.java:154)

	at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:83)

	at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1643)

	at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:85)

	at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:861)

	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435)

	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)

	at redis.clients.util.Pool.getResource(Pool.java:48)

	... 8 more

Caused by: java.net.ConnectException: Connection refused

	at java.net.PlainSocketImpl.socketConnect(Native Method)

	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)

	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)

	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

	at java.net.Socket.connect(Socket.java:589)

	at redis.clients.jedis.Connection.connect(Connection.java:148)

	... 15 more

Same with CodeRunner. I also tried with http://xxx.xxx.xxx.xxx, but it’s not effective either.

Hi Dylan,

I apologize, I hoped it would be a quick fix. I opened an internal ticket. If you need to check the status, ask about BKNDLSS-11640.

Regards,
Mark

Hi Mark,

After searching for the problem with a colleague. It appears that our Redis host doesn’t use the default port 6379. But use the 7738 port.
I updated the runner.properties to be my ip as the redis host and the port 7738 as the redis port.
And the deploying works! But nothing happens beyond that. BeforeCreate, Find, AfterCreate, BeforeRemove, etc. nothing seems to work.

On the other hand, I tried to run it with CodeRunner, to see if something happens. And surprise, there is a stimuli.
I created a BeforeCreate logic for the “Task” (custom) class that just Sysout “Hello” in the console.
And when I create a task, the coderunner displays an exception:

 
 
 
 
 
 
 
 
 
[INFO] Waiting for events...
févr. 08, 2016 8:00:25 AM com.backendless.coderunner.runtime.task.EventInvocationTask runImpl
GRAVE: argument type mismatch
java.lang.IllegalArgumentException: argument type mismatch
	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:497)
	at com.backendless.coderunner.runtime.task.EventInvocationTask.runImpl(EventInvocationTask.java:92)
	at com.backendless.coderunner.runtime.concurrent.ExtendedRunnable.run(ExtendedRunnable.java:22)



















	at java.lang.Thread.run(Thread.java:745)


Hope this helps. Thanks a lot for your help.

Hi Dylan,

Please try to download CodeRunner here: https://backendless.com/downloads/
Then replace all files except runner.properties inside the bin folder and try running it again.

So…

I deleted everything and retried with the new 3.0.0-16.

Here is my runner.properties:


# Application id
application.id = 3BE87088-27B7-D23E-****-8200EF221E00


# Code Runner ID assigned by Backendless Console.
application.secretKey = 33F6332E-E736-8CE6-****-61C2A5D43300


# 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 = http://vps******.ovh.net/api
system.redis.master.host = vps******.ovh.net
system.redis.master.port = 7738
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,\
vps******.ovh.net

I made a beforeCreate that set the price to 5.
I make a REST call to create an object, without setting it’s price.

If I run CodeRunner.sh:
It works. The object is created. The price is set to 5.

If I run Deploy.sh
The deploy returns no errors, and says “Thank you”.
BUT, when I create an object, the price is never set.

It’s a good start, but still not perfect.

Could you please check the Production tab on the Business Logic screen and make sure the event handler is listed there?

Yep, it is listed there. =/

http://support.backendless.com/public/attachments/7653c95dfac24660d76bc7400e81e5d7.png</img>

Do you use CodeRunner downloaded from console or from our website?

So your problem is that when deploying your custom code, the handlers aren’t invoked?

I use the one downloaded from your website.

And yes, that is exactly what happens. With the CodeRunners, handlers are called. But not when Deployed.

Hi Dylan,
We’ve finally found a problem.
Go to installdir/apps/backendless/htdocs/conf/billing.properties and change

EXECUTION_TIME.limit.free = 2147483647
EXECUTION_TIME.limit.level1 = 20

to this

EXECUTION_TIME.limit.free = 2000000
EXECUTION_TIME.limit.level1 = 2000000

(the value should be 2 million)

It works dude. Thanks a lot!