This is just to share my experiences trying to migrate my old OpenHABian instance running on java 8 for ages to a new one, running on java 11.
If you wonder why the Groovy ScriptEngine isn’t loaded anymore (resulting in ScriptEngine for groovy not available
messages) here’s why:
The groovy librarys (the ones extracted from the Groovy SDK zip) go usually to the runtime/lib/ext directory and are loaded by the JVM from there.
From Java 9 onwoards the whole mechanism of loading Extensions has been removed. (Refer to https://docs.oracle.com/javase/9/migrate/toc.htm#GUID-D867DCCC-CEB5-4AFA-9D11-9C62B7A3FAB1 “Removed Extension mechanism”). The advice is to just add JARs to the regular classpath, which worked for me (using * wildcard).
I did this by adding 2 lines to runtime/bin/karaf:
JAVA_9_ADD_CP_DIR="${KARAF_HOME}/lib/groovy/*"
after the line JAVA_EXT_DIRS=
…
and I changed the -classpath ...
to the following in the if [ "${VERSION}" -gt "8" ]; then
section:
-classpath "${CLASSPATH}:${JAVA_9_ADD_CP_DIR}" \
Then I moved all groovy jars (read: all jars in the directory) from runtime/lib/ext to a newly created runtime/lib/groovy and the scripts got loaded again.
HTH