Open apple-corps opened 2 years ago
Can you demonstrate how to reproduce this?
In Java 11 (IIRC), the scripting engine for JavaScript changed. In Java 8 the Nashorn engine was introduced, which replaced the older Rhino scripting engine. In Java 11 Nashorn is deprecated (and will be removed from JDK 15 onwards), with GraalVM being suggested as a replacement. However, Nashorn should still be able to be used from Java 11 and up...
(at least, according to https://en.wikipedia.org/wiki/Nashorn_(JavaScript_engine))
It seems that Rhino may still have been supported in Java 8... if you're experienceing an error about a missing script engine, it might be you have code that is expecting to use Rhino?
This would appear to be similar to https://github.com/jruby/jruby/issues/5446, which I see you've also commented on, but I can't tell if what you've posted is a reproducible for my repository or for another.
I've never used the aggregate plugin yet, although that would appear to be a pure-Ruby plugin.
Which version of Logstash etc. were you using?
Also, you say you saw this error after enabling logging. Can you describe what you did to enable logging?
Can you demonstrate how to reproduce this?
Hello,
Using your remote containers setup use the following dockerfile
Dockerfile
FROM cameronkerrnz/logstash-plugin-dev:7.13
#FROM drocsid/logstashdev8:001
RUN cd /src/logstash && bin/logstash-plugin install --development
RUN cd /src/logstash && rake test:install-core
RUN cd /src/logstash && rake test:install-default
RUN cd /src/logstash && bin/logstash-plugin install logstash-filter-dissect
RUN cd /src/logstash && bin/logstash-plugin install logstash-filter-aggregate
RUN cd /src/logstash && bin/logstash-plugin install logstash-filter-kv
RUN cd /src/logstash && bin/logstash-plugin install logstash-filter-json
Then you need to add a log4j2.properties to /src/logstash/log4j2.properties .
status = debug
name = LogstashRspecConfig
appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %m%n
rootLogger.level = debug
rootLogger.appenderRef.console.ref = console
Then you need to create a test spec and filter that utilize the aggregate plugin.
Here I provide an example but it is superfluous: https://github.com/logstash-plugins/logstash-filter-aggregate/issues/119#issue-1057149824. A filter which utilizes the aggregate plugin should be sufficient. Edit the ruby test to point to your filter and a test line.
Then trigger the test via rspec from /src/logstash/bin/rspec spec.rb
and you should see the message in the logging output.
I built your container with JDK 1.8 ( replace image above ) where I could not reproduce with that JDK. Unfortunatly it didn't fix the test failure on Error on https://github.com/logstash-plugins/logstash-filter-aggregate/issues/119 .
I am not sure if fixing this with JDK 1.11 will solve my testing issue.
Which version of Logstash etc. were you using?
The one from your container
Also, you say you saw this error after enabling logging. Can you describe what you did to enable logging?
Described above
It seems that Rhino may still have been supported in Java 8... if you're experienceing an error about a missing script engine, it might be you have code that is expecting to use Rhino?
I wasn't sure what the scripting engine error was about. I was hoping it was used as part of the logstash stack for test. I was trying to test my filters against logstash using the logstash-devutils
as described in https://github.com/elastic/logstash-devutils/issues/100. There was a hope that fixing the scripting might make the aggregate function under test. But my hopes are now dashed.
Does it only occur when you add the debug logging?
From my previous notes, the way I've generally set additional logging is
TEST_DEBUG=1 bundle exec rspec
You can also edit spec_helper.rb and set INFO logging.
I'll try and look at this in the next few days. I do seem to recall issues when I was trying to configure logging; I was quite happy when I found TEST_DEBUG.... it might just be wishful thinking, but I'd like to imagine it might have even experienced that same script engine error (but that was quite some time ago).
I've attached a presentation I once gave, slide 29 may be more interesting for your needs. (there are notes in the slides too, though I don't think I found the log4j2 stuff useful, but I'm a bit hazy on that ATM).
-- Cameron Kerr @.***>
On Tue, 30 Nov 2021 at 17:55, apple-corps @.***> wrote:
Can you demonstrate how to reproduce this?
Hello,
Using your remote containers setup use the following dockerfile
Dockerfile
FROM cameronkerrnz/logstash-plugin-dev:7.13
FROM drocsid/logstashdev8:001
RUN cd /src/logstash && bin/logstash-plugin install --development RUN cd /src/logstash && rake test:install-core RUN cd /src/logstash && rake test:install-default RUN cd /src/logstash && bin/logstash-plugin install logstash-filter-dissect RUN cd /src/logstash && bin/logstash-plugin install logstash-filter-aggregate RUN cd /src/logstash && bin/logstash-plugin install logstash-filter-kv RUN cd /src/logstash && bin/logstash-plugin install logstash-filter-json
Then you need to add a log4j2.properties to /src/logstash/log4j2.properties .
status = debug name = LogstashRspecConfig
appender.console.type = Consoleappender.console.name = console appender.console.layout.type = PatternLayout appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %m%n
rootLogger.level = debug rootLogger.appenderRef.console.ref = console
Then you need to create a test spec and filter that utilize the aggregate plugin.
Here I provide an example but it is superfluous: logstash-plugins/logstash-filter-aggregate#119 (comment) https://github.com/logstash-plugins/logstash-filter-aggregate/issues/119#issue-1057149824. A filter which utilizes the aggregate plugin should be sufficient. Edit the ruby test to point to your filter and a test line.
Then trigger the test and you should see the message in the logging output.
I built your container with JDK 1.8 ( replace image above ) where I could not reproduce with that JDK. Unfortunatly it didn't fix the test failure on Error on logstash-plugins/logstash-filter-aggregate#119 https://github.com/logstash-plugins/logstash-filter-aggregate/issues/119 .
I am not sure if fixing this with JDK 1.11 will solve my testing issue.
Which version of Logstash etc. were you using?
The one from your container
Also, you say you saw this error after enabling logging. Can you describe what you did to enable logging?
Described above
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cameronkerrnz/logstash-plugin-dev/issues/5#issuecomment-982284743, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHFFTTN7D7TO7JXA5WS3YLUORKLHANCNFSM5JAF6HVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Does it only occur when you add the debug logging?
If you look at the error output it looks like it comes out of INFO level logging:
2021-11-29 07:51:02,145 main INFO Cannot initialize scripting support because this JRE does not support it. java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
from https://github.com/logstash-plugins/logstash-filter-aggregate/issues/119#issuecomment-981384890
Then I assume it would occur if setting INFO logging. I believe we need to configure log4j to see these JVM related logs.
I've attached a presentation I once gave, slide 29 may be more interesting for your needs. (there are notes in the slides too, though I don't think I found the log4j2 stuff useful, but I'm a bit hazy on that ATM).
I checked my email and don't see any attachments. I haven't yet hooked up github to relay issues to my email. I don't see the attachment here in the issue web ui: https://github.com/cameronkerrnz/logstash-plugin-dev/issues/5
From my previous notes, the way I've generally set additional logging is
Thanks for the hint. That looks convenient.
I think this might be caused by the upstream JRuby. I was hoping that fixing the issue would allow my unit tests to get past the Error described in logstash-plugins/logstash-filter-aggregate#119 . However setting the JDK to 1.8 and rebuilding your container as I have shown above and I do not see the issue in the log lines. Then I assume that the "fix" is to use JDK 1.8 . Unfortunately it did not solve my problem.
I think this might be caused by a Jruby problem with JDK 1.11 and this logstash / jruby / etc container setup. Then you could probably close it if you like, as a fix might be required upstream.
Well described in https://github.com/jruby/jruby/issues/6950#issue-1066522481 . I now see a comment about this in the Dockerfile implying that the Script Engine works in 11. Then I assume the bug still exists here. Hopefully will resolve my testing issue.