jruby / jruby

JRuby, an implementation of Ruby on the JVM
https://www.jruby.org
Other
3.8k stars 924 forks source link

Cannot initialize scripting support because this JRE does not support it. java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory #6950

Open apple-corps opened 2 years ago

apple-corps commented 2 years ago

Debugging my issue running logstash rspec tests currently using https://github.com/cameronkerrnz/logstash-plugin-dev as the base container image for my dockerfile. After enabling logging I see Cannot initialize scripting support because this JRE does not support it. java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory . Log shared in another issue:

https://github.com/logstash-plugins/logstash-filter-aggregate/issues/119#issuecomment-981384890

jruby / java details

[builder@55345f2bf44d logstash]$ ./vendor/jruby/bin/jruby --version
jruby 9.2.16.0 (2.5.7) 2021-03-03 f82228dc32 OpenJDK 64-Bit Server VM 11.0.11+9-LTS on 11.0.11+9-LTS +jit [linux-x86_64]

First line of linked log ^^^ says Using system java: /usr/bin/java

builder@55345f2bf44d logstash]$ /usr/bin/java --version
openjdk 11.0.11 2021-04-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.11+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9-LTS, mixed mode, sharing)

If I'm correct then the JDK installation comes from https://github.com/cameronkerrnz/logstash-plugin-dev/blob/9efe7d1f5ae1faec98db50b6f50f15cc7438e3f2/Dockerfile#L12 since I'm using that container as a base, but I could be wrong.

apple-corps commented 2 years ago

Just noticing the top of the dockerfile mentions the Scripting https://github.com/cameronkerrnz/logstash-plugin-dev/blob/9efe7d1f5ae1faec98db50b6f50f15cc7438e3f2/Dockerfile#L5 suggesting it works. So we might also be solving a bug in the container https://hub.docker.com/r/cameronkerrnz/logstash-plugin-dev . Also if you have some friends from logstash they might know if there are some issues with the setup.

apple-corps commented 2 years ago

Using JDK 1.8 vs 1.11 and I didn't see the error:

https://github.com/cameronkerrnz/logstash-plugin-dev/issues/5#issuecomment-982284743

headius commented 2 years ago

JDK 8 (the 1.x numbers are generally not used much anymore) would not have this problem because all of the JDK is always available there.

JDK 11 would have this problem if it could not find the java.scripting module to activate. This should only happen if the JDK has been customized to remove that module.

You can check to see what modules are being used by looking in JDK_HOME/jmods. Here's my local install of JDK 11:

$ ls /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/jmods/
java.base.jmod                           java.scripting.jmod                      jdk.attach.jmod                          jdk.internal.opt.jmod                    jdk.jlink.jmod                           jdk.rmic.jmod
java.compiler.jmod                       java.se.jmod                             jdk.charsets.jmod                        jdk.internal.vm.ci.jmod                  jdk.jshell.jmod                          jdk.scripting.nashorn.jmod
java.datatransfer.jmod                   java.security.jgss.jmod                  jdk.compiler.jmod                        jdk.internal.vm.compiler.jmod            jdk.jsobject.jmod                        jdk.scripting.nashorn.shell.jmod
java.desktop.jmod                        java.security.sasl.jmod                  jdk.crypto.cryptoki.jmod                 jdk.internal.vm.compiler.management.jmod jdk.jstatd.jmod                          jdk.sctp.jmod
java.instrument.jmod                     java.smartcardio.jmod                    jdk.crypto.ec.jmod                       jdk.jartool.jmod                         jdk.localedata.jmod                      jdk.security.auth.jmod
java.logging.jmod                        java.sql.jmod                            jdk.dynalink.jmod                        jdk.javadoc.jmod                         jdk.management.agent.jmod                jdk.security.jgss.jmod
java.management.jmod                     java.sql.rowset.jmod                     jdk.editpad.jmod                         jdk.jcmd.jmod                            jdk.management.jfr.jmod                  jdk.unsupported.desktop.jmod
java.management.rmi.jmod                 java.transaction.xa.jmod                 jdk.hotspot.agent.jmod                   jdk.jconsole.jmod                        jdk.management.jmod                      jdk.unsupported.jmod
java.naming.jmod                         java.xml.crypto.jmod                     jdk.httpserver.jmod                      jdk.jdeps.jmod                           jdk.naming.dns.jmod                      jdk.xml.dom.jmod
java.net.http.jmod                       java.xml.jmod                            jdk.internal.ed.jmod                     jdk.jdi.jmod                             jdk.naming.rmi.jmod                      jdk.zipfs.jmod
java.prefs.jmod                          jdk.accessibility.jmod                   jdk.internal.jvmstat.jmod                jdk.jdwp.agent.jmod                      jdk.net.jmod
java.rmi.jmod                            jdk.aot.jmod                             jdk.internal.le.jmod                     jdk.jfr.jmod                             jdk.pack.jmod

Note that java.scripting.jmod does exist in that dir.

apple-corps commented 2 years ago

I'll take a look. We shouldn't expect them to be removed because we see the JDK package unless it was removed by centos (doubtful)

https://github.com/cameronkerrnz/logstash-plugin-dev/blob/9efe7d1f5ae1faec98db50b6f50f15cc7438e3f2/Dockerfile#L12