# \[Solved\] Problem using LDAP library in custom filter plugin

**URL:** https://discuss.elastic.co/t/solved-problem-using-ldap-library-in-custom-filter-plugin/41777
**Category:** Logstash
**Created:** [February 15, 2016, 12:07pm UTC](https://discuss.elastic.co/t/solved-problem-using-ldap-library-in-custom-filter-plugin/41777 "2016-02-15T12:07:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![twnone](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@twnone](https://discuss.elastic.co/u/twnone)
#### Post date: [February 15, 2016, 12:07pm UTC](https://discuss.elastic.co/t/solved-problem-using-ldap-library-in-custom-filter-plugin/41777/1 "2016-02-15T12:07:40Z")

</div>

Hi everyone !

I'm running Logstash 2.1.2 inside a docker container. My configuration specifies to read data into a file and indexes data into an ES cluster.

I developped a custom filter plugin that queries a LDAP server for informations, but whenever it tries to call the library 'net/ldap', it fails with this error message :

"{:timestamp=\>"2016-02-15T10:34:55.656000+0000", :message=\>"Exception in filterworker, the pipeline stopped processing new events, please check your filter configuration and restart Logstash.", "exception"=\># **\<LoadError: no such file to load -- net/ldap\>** , "backtrace"=\>["org/jruby/RubyKernel.java:1040:in `require'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/polyglot-0.3.5/lib/polyglot.rb:65:in`require'", "/opt/logstash/vendor/local\_gems/ab5428d7/logstash-filter-caparmor-0.0.1/lib/logstash/filters/caparmor.rb:872:in `addUserInformations'", "/opt/logstash/vendor/local_gems/ab5428d7/logstash-filter-caparmor-0.0.1/lib/logstash/filters/caparmor.rb:223:in`parse\_message'", "/opt/logstash/vendor/local\_gems/ab5428d7/logstash-filter-caparmor-0.0.1/lib/logstash/filters/caparmor.rb:41:in `filter'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.2-java/lib/logstash/filters/base.rb:151:in`multi\_filter'", "org/jruby/RubyArray.java:1613:in `each'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.2-java/lib/logstash/filters/base.rb:148:in`multi\_filter'", "(eval):1052:in `cond_func_33'", "org/jruby/RubyArray.java:1613:in`each'", "(eval):1049:in `cond_func_33'", "(eval):496:in`filter\_func'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.2-java/lib/logstash/pipeline.rb:244:in `filterworker'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.2-java/lib/logstash/pipeline.rb:178:in`start\_filters'"], :level=\>:error}  
LoadError: no such file to load -- net/ldap  
require at org/jruby/RubyKernel.java:1040  
require at /opt/logstash/vendor/bundle/jruby/1.9/gems/polyglot-0.3.5/lib/polyglot.rb:65  
addUserInformations at /opt/logstash/vendor/local\_gems/ab5428d7/logstash-filter-caparmor-0.0.1/lib/logstash/filters/caparmor.rb:872  
parse\_message at /opt/logstash/vendor/local\_gems/ab5428d7/logstash-filter-caparmor-0.0.1/lib/logstash/filters/caparmor.rb:223  
filter at /opt/logstash/vendor/local\_gems/ab5428d7/logstash-filter-caparmor-0.0.1/lib/logstash/filters/caparmor.rb:41  
multi\_filter at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.2-java/lib/logstash/filters/base.rb:151  
each at org/jruby/RubyArray.java:1613  
multi\_filter at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.2-java/lib/logstash/filters/base.rb:148  
cond\_func\_33 at (eval):1052  
each at org/jruby/RubyArray.java:1613  
cond\_func\_33 at (eval):1049  
filter\_func at (eval):496  
filterworker at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.2-java/lib/logstash/pipeline.rb:244  
start\_filters at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.1.2-java/lib/logstash/pipeline.rb:178  
"

I did not forget to install net-ldap library with "gem install net-ldap".  
My plugin also uses elasticsearch client library and it works well, so I don't really understand what's happening here.

This failure also happens if I try to use this plugin outside a docker container (with the latest version of LS).

When searching for this kind of problem, I met a topic that told to specify env variable GEM\_HOME, but it did not help.

I'm pretty lost with this stuff, so I hope someone will be able to help 🙂

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [February 15, 2016, 6:23pm UTC](https://discuss.elastic.co/t/solved-problem-using-ldap-library-in-custom-filter-plugin/41777/2 "2016-02-15T18:23:54Z")

</div>

I don't think running `gem install` in your shell is enough or a gem to be available when you run it in Logstash. I'd assume you'd have to specify that gem as a runtime dependency.

---

<div class="post-metadata">

### Author: ![twnone](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@twnone](https://discuss.elastic.co/u/twnone)
#### Post date: [February 16, 2016, 10:50am UTC](https://discuss.elastic.co/t/solved-problem-using-ldap-library-in-custom-filter-plugin/41777/3 "2016-02-16T10:50:57Z")

</div>

Hi, thanks for your answer.

Indeed, that was due to a bad way to declare dependency.

I managed to use net-ldap library thanks to [this page](http://stackoverflow.com/questions/25984620/how-to-add-gems-into-logstash)

Two steps helped me to accomplish this :

1. Installing the gem with this command : **env GEM\_HOME=/opt/logstash/vendor/bundle/jruby/1.9 /opt/logstash/vendor/jruby/bin/jruby /opt/logstash/vendor/jruby/bin/gem install net-ldap -v 0.12.0**
2. Adding **gem "net-ldap", "0.12.0"** in **/opt/logstash/Gemfile**

Works inside & outside docker containers ! ☀

---

<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:11am UTC](https://discuss.elastic.co/t/solved-problem-using-ldap-library-in-custom-filter-plugin/41777/4 "2017-07-06T05:11:14Z")

</div>


