In a Maven project I have tests that are using the Kotlin ScriptEngine (just calling scriptEngine.eval(script)). When I run the tests from IntelliJ they all pass, but during runs of mvn test, I am getting the following error:
javax.script.ScriptException: Cannot access script base class 'kotlin.script.experimental.jsr223.KotlinJsr223DefaultScript'. Check your module classpath for missing or conflicting dependencies
Cannot access script provided property class 'kotlin.script.experimental.jvmhost.jsr223.KotlinJsr223ScriptEngineImpl'. Check your module classpath for missing or conflicting dependencies
Cannot access script provided property class 'org.jetbrains.kotlin.cli.common.repl.AggregatedReplStageState'. Check your module classpath for missing or conflicting dependencies
I have these three classes in the classpath via appropriate Maven dependencies. (I actually added a call to System.out.println(KotlinJsr223DefaultScript.class.getName()) in the failing tests to make sure it's the case.) Here's the relevant fragment of the dependency tree:
[INFO] | \- org.jetbrains.kotlin:kotlin-scripting-jsr223:jar:1.3.72:compile
[INFO] | +- org.jetbrains.kotlin:kotlin-script-runtime:jar:1.3.72:compile
[INFO] | +- org.jetbrains.kotlin:kotlin-scripting-common:jar:1.3.72:compile
[INFO] | | \- org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:1.2.1:compile
[INFO] | +- org.jetbrains.kotlin:kotlin-scripting-jvm:jar:1.3.72:compile
[INFO] | +- org.jetbrains.kotlin:kotlin-scripting-jvm-host:jar:1.3.72:compile
[INFO] | | \- org.jetbrains.intellij.deps:trove4j:jar:1.0.20181211:runtime
[INFO] | +- org.jetbrains.kotlin:kotlin-scripting-compiler:jar:1.3.72:compile
[INFO] | | +- org.jetbrains.kotlin:kotlin-scripting-js:jar:1.3.72:compile
[INFO] | | +- org.jetbrains.kotlin:kotlin-util-klib:jar:1.3.72:compile
[INFO] | | | \- org.jetbrains.kotlin:kotlin-util-io:jar:1.3.72:compile
[INFO] | | \- org.jetbrains.kotlin:kotlin-scripting-compiler-impl:jar:1.3.72:compile
[INFO] | +- org.jetbrains.kotlin:kotlin-compiler:jar:1.3.72:runtime
[INFO] | \- org.jetbrains.kotlin:kotlin-reflect:jar:1.3.72:runtime
I saw people on the Internet run into similar issues, but their solution was to make sure the classes are available on the classpath, which I already have.