Backendless Support
 
Answered

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)

  1. # This is main configuration file for Code Runner
  2. # Application id
  3. application.id = D58FD012-****-B9C6-****-CD8555A33C00
  4. # Code Runner ID assigned by Backendless Console.
  5. application.secretKey = AE211FA6-****-6A48-****-F48E0D3BE900
  6. # Application version name
  7. # Default: v1
  8. application.version = v1
  9. # Optional argument. Search path for classes which will be used for debugging or publishing.
  10. # By default Code Runner looks for the ./build/classes directory located in the current directory
  11. location.classes = ../classes/
  12. # Optional argument. Search path for jar files which are the dependencies for the code which is debugged or published.
  13. # By default Code Runner looks for the ./build/libs directory located in the current directory.
  14. location.jar = ../libs/
  15. # System properties
  16. # Don't touch, if you do not really understand this
  17. system.server.url = http://51.*.*.114/api
  18. system.redis.master.host = cl.backendless.com
  19. system.redis.master.port = 6379
  20. system.pool.core = 20
  21. system.type = LOCAL
  22. system.repo.path = ../repo/
  23. enterprise.allowedHosts = api.backendless.com,\
  24. api.backendless.com,\
  25. localhost,\
  26. localhost:9000,\
  27. api.gmo-mbaas.com,\
  28. 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):

  1. public class TestTimerTimer extends TimerExtender
  2. {
  3. @Override
  4. public void execute( String appVersionId ) throws Exception
  5. {
  6. Task task = new Task();
  7. task.setTitle("PRETTY PLEASE");
  8. Backendless.Persistence.of(Task.class).save(task);
  9. }
  10. }

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.

Leave a Comment

Comments (12)

photo
1

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

photo
1

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:

  1. [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.

photo
2

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

photo
1

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:

  1. [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.

photo
1

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.

photo
1

So....

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

Here is my runner.properties:

  1. # Application id
  2. application.id = 3BE87088-27B7-D23E-****-8200EF221E00
  3. # Code Runner ID assigned by Backendless Console.
  4. application.secretKey = 33F6332E-E736-8CE6-****-61C2A5D43300
  5. # Application version name
  6. # Default: v1
  7. application.version = v1
  8. # Optional argument. Search path for classes which will be used for debugging or publishing.
  9. # By default Code Runner looks for the ./build/classes directory located in the current directory
  10. location.classes = ../classes/
  11. # Optional argument. Search path for jar files which are the dependencies for the code which is debugged or published.
  12. # By default Code Runner looks for the ./build/libs directory located in the current directory.
  13. location.jar = ../libs/
  14. # System properties
  15. # Don't touch, if you do not really understand this
  16. system.server.url = http://vps******.ovh.net/api
  17. system.redis.master.host = vps******.ovh.net
  18. system.redis.master.port = 7738
  19. system.pool.core = 20
  20. system.type = LOCAL
  21. system.repo.path = ../repo/
  22. enterprise.allowedHosts = api.backendless.com,\
  23. api.backendless.com,\
  24. localhost,\
  25. localhost:9000,\
  26. api.gmo-mbaas.com,\
  27. 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.

photo
1

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

photo
1

Yep, it is listed there. =/

7653c95dfac24660d76bc7400e81e5d7

photo
1

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?

photo
1

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.

photo
1

Hi Dylan,

We've finally found a problem.

Go to installdir/apps/backendless/htdocs/conf/billing.properties and change

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

to this

  1. EXECUTION_TIME.limit.free = 2000000
  2. EXECUTION_TIME.limit.level1 = 2000000

(the value should be 2 million)

photo
1

It works dude. Thanks a lot!