# Writing a Logstash GEM gives an error: undefined local variable or method

**URL:** <https://discuss.elastic.co/t/writing-a-logstash-gem-gives-an-error-undefined-local-variable-or-method/34422>\
**Category:** Logstash\
**Created:** [November 12, 2015, 2:22pm UTC](https://discuss.elastic.co/t/writing-a-logstash-gem-gives-an-error-undefined-local-variable-or-method/34422 "2015-11-12T14:22:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isra](https://avatars.discourse-cdn.com/v4/letter/i/7ba0ec/32.png) [@Isra](https://discuss.elastic.co/u/Isra)\
**Post date:** [November 12, 2015, 2:22pm UTC](https://discuss.elastic.co/t/writing-a-logstash-gem-gives-an-error-undefined-local-variable-or-method/34422/1 "2015-11-12T14:22:46Z")

</div>

Trying to build a gem to use it for Logstash as a filter. I'm using classes and methods from a .jar file.

The following is my Jruby code so far:

```
require 'java'
require 'Processing.jar'

$CLASSPATH << 'lib'

class LogStash::Filters::Processing < LogStash::Filters::Base

    config_name "process"
    score = JavaUtilities.get_proxy_class('process.Process')  
    @score = score.new ("/path/")

  public
  def register
  end

  public
  def filter(event)
    if @text
      event["NewField"] = @score.myMethod(event[@text])
    end
    filter_matched(event)
  end

end

```

However, it gave me the following error:

```
undefined local variable or method score.myMethod(event["text"])

```

So, I tried the following:

```
  .
  .
  .
  public
  def filter(event)
        score = JavaUtilities.get_proxy_class('process.Process')  
        @score = score.new ("/path/")
        event["NewField"] = @score.myMethod(@text)
        filter_matched(event)
  end   
end

```

But it gave me the error:

```
> SyntaxError: dynamic constant assignment error. 

```

Please note that I tried this in a normal jruby file and everything worked with me. Using Logstash's filter however is what seems to be giving me an issue here.. Any help? PLEASE!!!

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 5:23am UTC](https://discuss.elastic.co/t/writing-a-logstash-gem-gives-an-error-undefined-local-variable-or-method/34422/2 "2017-07-06T05:23:03Z")

</div>

Closed on July 6, 2017, 5:23am UTC


