Error starting Logstash pipeline after upgrading to Java 17

I have bundled Logstash within my Java application and launch it using JRuby. It worked fine until upgrading to Java 17. After upgrading, the pipeline fails to start with following exception :

java.lang.IllegalAccessError: class com.google.googlejavaformat.java.JavaInput (in unnamed module @0x7df34a68) cannot access class com.sun.tools.javac.parser.Tokens$TokenKind (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.parser to unnamed module @0x7df34a68Thu 05 25 14:48:24:925 UTC 2023 at com.google.googlejavaformat.java.JavaInput.buildToks(com/google/googlejavaformat/java/JavaInput.java:349)
Thu 05 25 14:48:24:925 UTC 2023 at com.google.googlejavaformat.java.JavaInput.buildToks(com/google/googlejavaformat/java/JavaInput.java:334)
Thu 05 25 14:48:24:925 UTC 2023 at com.google.googlejavaformat.java.JavaInput.(com/google/googlejavaformat/java/JavaInput.java:276)
Thu 05 25 14:48:24:925 UTC 2023 at com.google.googlejavaformat.java.Formatter.getFormatReplacements(com/google/googlejavaformat/java/Formatter.java:260)
Thu 05 25 14:48:24:925 UTC 2023 at com.google.googlejavaformat.java.Formatter.formatSource(com/google/googlejavaformat/java/Formatter.java:247)
Thu 05 25 14:48:24:925 UTC 2023 at com.google.googlejavaformat.java.Formatter.formatSource(com/google/googlejavaformat/java/Formatter.java:213)
Thu 05 25 14:48:24:925 UTC 2023 at org.logstash.config.ir.compiler.ComputeStepSyntaxElement.generateCode(org/logstash/config/ir/compiler/ComputeStepSyntaxElement.java:174)
Thu 05 25 14:48:24:925 UTC 2023 at org.logstash.config.ir.compiler.ComputeStepSyntaxElement.(org/logstash/config/ir/compiler/ComputeStepSyntaxElement.java:118)
Thu 05 25 14:48:24:925 UTC 2023 at org.logstash.config.ir.compiler.ComputeStepSyntaxElement.create(org/logstash/config/ir/compiler/ComputeStepSyntaxElement.java:89)

I added JVM options --add-exports in the jvm.options file within config based on the recommendation here : [Java17] Add `--add-export` settings to restore JDK17 compatibility by robbavey · Pull Request #13825 · elastic/logstash · GitHub

Although the error is still not resolved. Any help would be appreciated.

This issue has a larger set of add-exports/add-opens options that are used to fix this in a different app.

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