# Logstash java codec running error

**URL:** <https://discuss.elastic.co/t/logstash-java-codec-running-error/190128>\
**Category:** Logstash\
**Created:** [July 12, 2019, 2:49am UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128 "2019-07-12T02:49:25Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhi\_asher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhi_asher/32/49953_2.png) [@zhi\_asher](https://discuss.elastic.co/u/zhi_asher)\
**Post date:** [July 12, 2019, 2:49am UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/1 "2019-07-12T02:49:25Z")

</div>

HI，@danhermann，I'm from github issue ([https://github.com/elastic/logstash/issues/10680](https://github.com/elastic/logstash/issues/10680)), the promble transf here

```
logstash compile version: 7.1.2, logstash running version: 7.1.1

```

java\_codec\_example.rb file content

# encoding: utf-8  
require "logstash/codecs/base"  
require "logstash/namespace"  
require "logstash-codec-java\_codec\_example\_jars"  
require "java"

class LogStash::Codecs::JavaCodecExample \< LogStash::Codecs::Base  
config\_name "java\_codec\_example"  
def self.javaClass() org.logstash.javaapi.JavaCodecExample.java\_class; end  
end

logstash-codec-java\_codec\_example\_jars.rb file content

require 'jar\_dependencies'  
require\_jar('org.logstash.javaapi', 'logstash-codec-java\_codec\_example', '7.1.2')

logstash-codec-java\_codec\_example.gemspec file content

Gem::Specification.new do |s|  
s.name = 'logstash-codec-java\_codec\_example'  
s.version = '7.1.2'  
s.licenses = ['Apache-2.0']  
s.summary = "Example codec using Java plugin API"  
s.description = ""  
s.authors = ['Elasticsearch']  
s.email = 'info@elastic.co'  
s.homepage = "[http://www.elastic.co/guide/en/logstash/current/index.html](http://www.elastic.co/guide/en/logstash/current/index.html)"  
s.require\_paths = ['lib', 'vendor/jar-dependencies']

# Files  
s.files = Dir["lib/ **/\*","spec/** /_","_.gemspec","_.md","CONTRIBUTORS","Gemfile","LICENSE","NOTICE.TXT", "vendor/jar-dependencies/\*\*/_.jar", "vendor/jar-dependencies/ **/\*.rb", "VERSION", "docs/** /\*"]

# Special flag to let us know this is actually a logstash plugin  
s.metadata = { 'logstash\_plugin' =\> 'true', 'logstash\_group' =\> 'codec'}

# Gem dependencies  
s.add\_runtime\_dependency "logstash-core-plugin-api", "\>= 1.60", "\<= 2.99"  
s.add\_runtime\_dependency 'jar-dependencies'

s.add\_development\_dependency 'logstash-devutils'  
end

not set logstash config file，logstash run command：

```
./bin/logstash --debug --verbose --java-execution -e 'input { java_stdin { codec => java_codec_example } }'

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/2/4214174574aaa639f7d75a675c9b7035dc3f03ec.jpeg)

---

<div class="post-metadata">

**Author:** ![danhermann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danhermann/32/33024_2.png) [@danhermann](https://discuss.elastic.co/u/danhermann)\
**Post date:** [July 12, 2019, 11:36am UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/2 "2019-07-12T11:36:08Z")

</div>

@zhi_asher, thanks for the additional detail. Can you confirm that you installed the codec plugin using the `logstash-plugin` utility as documented here: [https://www.elastic.co/guide/en/logstash/7.1/java-codec-plugin.html#\_installing\_the\_java\_plugin\_in\_logstash\_2](https://www.elastic.co/guide/en/logstash/7.1/java-codec-plugin.html#_installing_the_java_plugin_in_logstash_2)

You should also be able to run `bin/logstash-plugin list` and see `logstash-codec-java_codec_example` in the output.

---

<div class="post-metadata">

**Author:** ![zhi\_asher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhi_asher/32/49953_2.png) [@zhi\_asher](https://discuss.elastic.co/u/zhi_asher)\
**Post date:** [July 13, 2019, 1:53am UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/3 "2019-07-13T01:53:41Z")

</div>

@danhermann，already installed and bin/logstash-plugin list see logstash-codec-java\_codec\_example in the output

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/7/b7ec25995c38baab774a311ac22acedc32d8e52e.jpeg)

There is an error in the link content of the document ?

echo "foo,bar" | bin/logstash --java-execution -e 'input { java\_stdin { codec =\> java\_codec\_example } } }'

to

echo "foo,bar" | bin/logstash --java-execution -e 'input { java\_stdin { codec =\> java\_codec\_example } }'

---

<div class="post-metadata">

**Author:** ![danhermann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danhermann/32/33024_2.png) [@danhermann](https://discuss.elastic.co/u/danhermann)\
**Post date:** [July 16, 2019, 12:52pm UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/4 "2019-07-16T12:52:59Z")

</div>

@zhi_asher, you are correct that there is an error in the example execution statement. There should be only two closing braces and I'll get that fixed.

As for your plugin, I see no problems in what you've posted so far. At this point, I'd probably need all of the entire source to determine where the problem is. One thing I would suggest is testing with Logstash 7.2 if you're able. That version contains the GA release for Java plugins and it automatically generates all the Ruby "glue" code so there is a much reduced likelihood of naming or versioning mismatches.

---

<div class="post-metadata">

**Author:** ![zhi\_asher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhi_asher/32/49953_2.png) [@zhi\_asher](https://discuss.elastic.co/u/zhi_asher)\
**Post date:** [July 17, 2019, 2:52am UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/5 "2019-07-17T02:52:13Z")

</div>

@danhermann，source code:

> **[logstash-codec-java\_codec\_example.zip](https://drive.google.com/file/d/1HR51hsTdL4pWn9u0fzqvfw1TcIM-68kY/view?usp=sharing)**
>
> Google Drive file.

---

<div class="post-metadata">

**Author:** ![danhermann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danhermann/32/33024_2.png) [@danhermann](https://discuss.elastic.co/u/danhermann)\
**Post date:** [July 17, 2019, 12:05pm UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/6 "2019-07-17T12:05:05Z")

</div>

Thanks, @zhi_asher. Can you update that Google Drive sharing link to allow me to download the file so I can try it locally on my machine? Right now, it does not appear to allow me to download or copy the file.

---

<div class="post-metadata">

**Author:** ![zhi\_asher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhi_asher/32/49953_2.png) [@zhi\_asher](https://discuss.elastic.co/u/zhi_asher)\
**Post date:** [July 17, 2019, 1:44pm UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/7 "2019-07-17T13:44:18Z")

</div>

logstash 7.2.0 is OK, use new java\_codec\_example github repo

---

<div class="post-metadata">

**Author:** ![danhermann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danhermann/32/33024_2.png) [@danhermann](https://discuss.elastic.co/u/danhermann)\
**Post date:** [July 17, 2019, 3:03pm UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/8 "2019-07-17T15:03:11Z")

</div>

Great, glad to hear it's working for you now.

---

<div class="post-metadata">

**Author:** ![zhi\_asher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhi_asher/32/49953_2.png) [@zhi\_asher](https://discuss.elastic.co/u/zhi_asher)\
**Post date:** [July 18, 2019, 2:13am UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/9 "2019-07-18T02:13:08Z")

</div>

Thanks @danhermann, Google Drive sharing link to allow your to download the file

---

<div class="post-metadata">

**Author:** ![danhermann](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danhermann/32/33024_2.png) [@danhermann](https://discuss.elastic.co/u/danhermann)\
**Post date:** [July 20, 2019, 3:34pm UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/10 "2019-07-20T15:34:44Z")

</div>

@zhi_asher, I'm not sure if I understood you. Were you able to get your codec to work in Logstash 7.2 or were you still having problems with it?

---

<div class="post-metadata">

**Author:** ![zhi\_asher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhi_asher/32/49953_2.png) [@zhi\_asher](https://discuss.elastic.co/u/zhi_asher)\
**Post date:** [July 26, 2019, 3:06am UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/11 "2019-07-26T03:06:28Z")

</div>

no problems

---

<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:** [August 23, 2019, 3:06am UTC](https://discuss.elastic.co/t/logstash-java-codec-running-error/190128/12 "2019-08-23T03:06:30Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
