@sleshJdev (Eugene) posted a new topic, subject "Failed to run lua multi module aggregation function using java client. Module not found error". It read:

   Hi
    
    Let's just cat to the chase. I want to create mini LUA framework(set of UDF) allowing us to run different aggregations on the aerospike. Here you may find toy project which demonstrates it. Everything works fine while I run my function using aql. But when I want to call my func from the java application using `com.aerospike.client.AerospikeClient#queryAggregate(com.aerospike.client.policy.QueryPolicy, com.aerospike.client.query.Statement)` I start getting errors like `org.luaj.vm2.LuaError: demo:1 module 'person_pb' not found: person_pb`. This demo app is mostly inspired by Protobuf Module Example and Implementing SQL Operations: Aggregates (Part 1, Part 2), I just combined them together. I tried different workaround to provide all the required modules but it always failes because next **required** module missing.
    
    When I try to provide missing moduel(just put it near to module I am calling) it starts compaining aboud missing module protobuf. I also tried to use `com.aerospike.client.IAerospikeClient#register(com.aerospike.client.policy.Policy, java.lang.String, java.lang.String, com.aerospike.client.Language)`, play with `com.aerospike.client.lua.LuaConfig#SourceDirectory` \- nothing works to me. So, literally to get it working I need to pull all the source of lua modules from AS server to my local machine.
    
    Could someone please take a look at the demo project and help me/explain how to get testJavaAerospikeClient test case passed? I want it to be work the same as aql version testAqlIsAbleToCallLuaFuncToConvertDecodeProtoDigestAndReturnJson.
    
    Also, I'd appropriate if for explanation, why java client cannot make call lua module on AS side remotely and get the result. Why so much ceremony with loading/compiling lua code on the client side? Is there any way how to skip this step and ask client just call remote function and get the result?
    
    I'll highly appreciate for any advice in solving problem. Thanks in advance.

After which, @neelp added

    Please try registering the stream (aggregation) UDF module with a client API call and also setting LuaConfig.SourceDirectory if the client side module location is not ./udf. Please see the code in this code cell in the tutorial SQL Operations: Aggregates (Part 1).
    
    You must register a stream UDF module on the client before calling the stream UDF function as a stream function is executed both on the server side and the client side. The execution model is explained in the tutorial here. For a record UDF (which is executed only on the server side), a client registration is not required if the module is already registered on the server.

Then @sleshJdev (Eugene) said

    Does it mean, if one of my modules requires _protobuf_ , it should be in LuaConfig.SourceDirectory on client side? Literally, all the code I am going to run, should be available on the client side, not just on the server?

After which, @neelp added

    You could remove dependencies in the client-side code on the protobuf module (and other modules) by only keeping dummy definitions of the “server-side only” stream functions. Clearly all modules required for client-side stream processing must be present. For record UDFs, no client resident code should be required.


{'source': 'discourse', 'url': 'https://discuss.aerospike.com/t/failed-to-run-lua-multi-module-aggregation-function-using-java-client-module-not-found-error/9080', 'title': 'Failed to run lua multi module aggregation function using java client. Module not found error', 'views': 450, 'has_accepted_answer': False, 'word_count': 604, 'like_count': 0, 'reply_count': 2, 'participant_count': 2, 'posts': 4, 'tags': 'query java error', 'author': '@sleshJdev (Eugene)', 'participants': '@sleshJdev (Eugene), @neelp', 'image_url': [None], 'created_at': '2021-12-14T23:18:46.799Z', 'last_posted_at': '2021-12-21T16:46:16.326Z'}