How to implement java interface in jruby


Hi there,
I have a ruby script as follows:

class MyScript
# Import the interface required by the Script snap.
include com.snaplogic.scripting.language.ScriptHook
attr_reader :log, :input, :output, :error
def initialize(log, input, output, error)
@log = log
@input = input
@output = output
@error = error

# The "execute()" method is called once when the pipeline is started
# and allowed to process its inputs or just send data to its outputs.
def execute()
    while input.hasNext() do
            # Read the next document, wrap it in a map and write out the wrapper
            doc =
            wrapper = {
             "original" => doc
  "Executed Ruby script")
            output.write(doc, wrapper)
        rescue => e
            log.error("Bad Rublet " + e.message)
            errWrapper = {
                "errMsg" => e.message


The Script Snap will look for a ScriptHook object in the “hook”

variable. The snap will then call the hook’s “execute” method.

$hook =$log, $input, $output, $error)


When I trying to execute it, I am getting this error:

com.snaplogic.api.ExecutionException: (NoMethodError) undefined method hasNext' for nil:NilClass at com.snaplogic.snaps.script.CommonExecute.execute( at at at at$000( at$ at$ at java.base/ Method) at java.base/ at at at at java.base/ at java.base/java.util.concurrent.Executors$ at java.base/ at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker( at java.base/java.util.concurrent.ThreadPoolExecutor$ at java.base/ Caused by: org.jruby.exceptions.NoMethodError: (NoMethodError) undefined methodhasNext’ for nil:NilClass
at RUBY.execute(:16)


Any help pls?

In order words, can you give me a JRuby example for Java 11 where an interface is implemented and also the object initialized properly? thnaks.