I found this thread which seems to be related but the org.jetbrains.kotlin:kotlin-compiler-client-embeddable
mentioned there is already on my classpath. I ran mvn -X test
to get the (compact) class path:
annotations-13.0.jar
classes
eventbus-1.4.jar
hamcrest-core-1.3.jar
junit-4.13.jar
kotlin-compiler-client-embeddable-1.4.21.jar
kotlin-compiler-embeddable-1.4.21.jar
kotlin-daemon-embeddable-1.4.21.jar
kotlin-reflect-1.4.21.jar
kotlin-scripting-common-1.4.21.jar
kotlin-scripting-compiler-embeddable-1.4.21.jar
kotlin-scripting-compiler-impl-embeddable-1.4.21.jar
kotlin-scripting-jsr223-1.4.21.jar
kotlin-scripting-jvm-1.4.21.jar
kotlin-scripting-jvm-host-1.4.21.jar
kotlin-script-runtime-1.4.21.jar
kotlin-stdlib-1.4.21.jar
kotlin-stdlib-common-1.4.21.jar
kotlin-stdlib-jdk7-1.4.21.jar
kotlin-stdlib-jdk8-1.4.21.jar
kotlinx-coroutines-core-1.3.7.jar
parsington-2.0.0.jar
scijava-common-2.83.3.jar
scijava-common-2.83.3-tests.jar
surefire-api-2.22.2.jar
surefire-booter-2.22.2.jar
surefire-junit4-2.22.2.jar
surefire-logger-api-2.22.2.jar
test-classes
trove4j-1.0.20181211.jar
When I “manually” run the tests by including the classpath and the compiled classes, the tests run successfully on the command line ($CLASSPATH
generated from mvn -X
output):
$ java \
-classpath target/test-classes:target/classes:$CLASSPATH \
org.junit.runner.JUnitCore \
org.scijava.plugins.scripting.kotlin.KotlinTest
JUnit version 4.13
...
Time: 5.681
OK (3 tests)
This may be a Maven issue, then, but I don’t know how maven invokes the tests (I will dig through the logs more).
These are my java/maven versions:
$ java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)
$ mvn -version
Apache Maven 3.6.3 (NON-CANONICAL_2019-11-27T20:26:29Z_root)
Maven home: /opt/maven
Java version: 1.8.0_265, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-8-openjdk/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.9.11-3-manjaro", arch: "amd64", family: "unix"
I dug a little deeper, and I found this command:
/usr/lib/jvm/java-8-openjdk/jre/bin/java -javaagent:$HOME/.m2/repository/org/jacoco/org.jacoco.agent/0.8.5/org.jacoco.agent-0.8.5-runtime.jar=destfile=$HOME/workspace/imklib/scripting-kotlin/target/jacoco.exec -Xms512m -Xmx512m -Dapple.awt.UIElement=true -jar $HOME/workspace/imklib/scripting-kotlin/target/surefire/surefirebooter8529160978234802859.jar $HOME/workspace/imklib/scripting-kotlin/target/surefire 2020-12-30T21-21-46_247-jvmRun1 surefire1784248447999292297tmp surefire_02431358075125921564tmp
which fails with a similar/the same error as far as I can tell. The jar contains only a manifest
$ jar tf $HOME/workspace/imklib/scripting-kotlin/target/surefire/surefirebooter8529160978234802859.jar
META-INF/MANIFEST.MF
with Manifest-Version: 1.0
, Main-Class: org.apache.maven.surefire.booter.ForkedBooter
, and Class-Path
(modified for readability):
$HOME/.m2/repository/junit/junit/4.13/junit-4.13.jar
$HOME/.m2/repository/org/apache/maven/surefire/surefire-api/2.22.2/surefire-api-2.22.2.jar
$HOME/.m2/repository/org/apache/maven/surefire/surefire-booter/2.22.2/surefire-booter-2.22.2.jar
$HOME/.m2/repository/org/apache/maven/surefire/surefire-junit4/2.22.2/surefire-junit4-2.22.2.jar
$HOME/.m2/repository/org/apache/maven/surefire/surefire-logger-api/2.22.2/surefire-logger-api-2.22.2.jar
$HOME/.m2/repository/org/bushe/eventbus/1.4/eventbus-1.4.jar
$HOME/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
$HOME/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar
$HOME/.m2/repository/org/jetbrains/intellij/deps/trove4j/1.0.20181211/trove4j-1.0.20181211.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-compiler-client-embeddable/1.4.21/kotlin-compiler-client-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.4.21/kotlin-compiler-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-daemon-embeddable/1.4.21/kotlin-daemon-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.4.21/kotlin-reflect-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-common/1.4.21/kotlin-scripting-common-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.4.21/kotlin-scripting-compiler-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler-impl-embeddable/1.4.21/kotlin-scripting-compiler-impl-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jsr223/1.4.21/kotlin-scripting-jsr223-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm/1.4.21/kotlin-scripting-jvm-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm-host/1.4.21/kotlin-scripting-jvm-host-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-script-runtime/1.4.21/kotlin-script-runtime-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.4.21/kotlin-stdlib-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.21/kotlin-stdlib-common-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.4.21/kotlin-stdlib-jdk7-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.4.21/kotlin-stdlib-jdk8-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.3.7/kotlinx-coroutines-core-1.3.7.jar
$HOME/.m2/repository/org/scijava/parsington/2.0.0/parsington-2.0.0.jar
$HOME/.m2/repository/org/scijava/scijava-common/2.83.3/scijava-common-2.83.3.jar
$HOME/.m2/repository/org/scijava/scijava-common/2.83.3/scijava-common-2.83.3-tests.jar
$HOME/workspace/imklib/scripting-kotlin/target/classes/
$HOME/workspace/imklib/scripting-kotlin/target/test-classes/
or only basenames
annotations-13.0.jar
classes/
eventbus-1.4.jar
hamcrest-core-1.3.jar
junit-4.13.jar
kotlin-compiler-client-embeddable-1.4.21.jar
kotlin-compiler-embeddable-1.4.21.jar
kotlin-daemon-embeddable-1.4.21.jar
kotlin-reflect-1.4.21.jar
kotlin-scripting-common-1.4.21.jar
kotlin-scripting-compiler-embeddable-1.4.21.jar
kotlin-scripting-compiler-impl-embeddable-1.4.21.jar
kotlin-scripting-jsr223-1.4.21.jar
kotlin-scripting-jvm-1.4.21.jar
kotlin-scripting-jvm-host-1.4.21.jar
kotlin-script-runtime-1.4.21.jar
kotlin-stdlib-1.4.21.jar
kotlin-stdlib-common-1.4.21.jar
kotlin-stdlib-jdk7-1.4.21.jar
kotlin-stdlib-jdk8-1.4.21.jar
kotlinx-coroutines-core-1.3.7.jar
parsington-2.0.0.jar
scijava-common-2.83.3.jar
scijava-common-2.83.3-tests.jar
surefire-api-2.22.2.jar
surefire-booter-2.22.2.jar
surefire-junit4-2.22.2.jar
surefire-logger-api-2.22.2.jar
test-classes/
trove4j-1.0.20181211.jar
which is the same classpath as the I used in the java
command above that worked for me. I suspect that something in Main-Class: org.apache.maven.surefire.booter.ForkedBooter
causes the issue.
Update: I also noticed, that the order of files in the classpath matters. For better readability, I sorted the classpath entries for the forum, but when manually invoking java ... org.junit.runner.JunitCore ...
, I did not sort the classpath. When I c&p’ed the classpath from the forum and tried running the same command, it failed.
This classpath works:
$HOME/.m2/repository/org/apache/maven/surefire/surefire-booter/2.22.2/surefire-booter-2.22.2.jar
$HOME/.m2/repository/org/apache/maven/surefire/surefire-api/2.22.2/surefire-api-2.22.2.jar
$HOME/.m2/repository/org/apache/maven/surefire/surefire-logger-api/2.22.2/surefire-logger-api-2.22.2.jar
$HOME/workspace/imklib/scripting-kotlin/target/test-classes/
$HOME/workspace/imklib/scripting-kotlin/target/classes/
$HOME/.m2/repository/org/scijava/scijava-common/2.83.3/scijava-common-2.83.3.jar
$HOME/.m2/repository/org/scijava/parsington/2.0.0/parsington-2.0.0.jar
$HOME/.m2/repository/org/bushe/eventbus/1.4/eventbus-1.4.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.4.21/kotlin-compiler-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.4.21/kotlin-stdlib-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.21/kotlin-stdlib-common-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-script-runtime/1.4.21/kotlin-script-runtime-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.4.21/kotlin-reflect-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-daemon-embeddable/1.4.21/kotlin-daemon-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/intellij/deps/trove4j/1.0.20181211/trove4j-1.0.20181211.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.4.21/kotlin-stdlib-jdk8-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.4.21/kotlin-stdlib-jdk7-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jsr223/1.4.21/kotlin-scripting-jsr223-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-common/1.4.21/kotlin-scripting-common-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm/1.4.21/kotlin-scripting-jvm-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm-host/1.4.21/kotlin-scripting-jvm-host-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.4.21/kotlin-scripting-compiler-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-compiler-client-embeddable/1.4.21/kotlin-compiler-client-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler-impl-embeddable/1.4.21/kotlin-scripting-compiler-impl-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.3.7/kotlinx-coroutines-core-1.3.7.jar
$HOME/.m2/repository/junit/junit/4.13/junit-4.13.jar
$HOME/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
$HOME/.m2/repository/org/scijava/scijava-common/2.83.3/scijava-common-2.83.3-tests.jar
$HOME/.m2/repository/org/apache/maven/surefire/surefire-junit4/2.22.2/surefire-junit4-2.22.2.jar
This one does not:
HOME/.m2/repository/junit/junit/4.13/junit-4.13.jar
$HOME/.m2/repository/org/apache/maven/surefire/surefire-api/2.22.2/surefire-api-2.22.2.jar
$HOME/.m2/repository/org/apache/maven/surefire/surefire-booter/2.22.2/surefire-booter-2.22.2.jar
$HOME/.m2/repository/org/apache/maven/surefire/surefire-junit4/2.22.2/surefire-junit4-2.22.2.jar
$HOME/.m2/repository/org/apache/maven/surefire/surefire-logger-api/2.22.2/surefire-logger-api-2.22.2.jar
$HOME/.m2/repository/org/bushe/eventbus/1.4/eventbus-1.4.jar
$HOME/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
$HOME/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar
$HOME/.m2/repository/org/jetbrains/intellij/deps/trove4j/1.0.20181211/trove4j-1.0.20181211.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-compiler-client-embeddable/1.4.21/kotlin-compiler-client-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.4.21/kotlin-compiler-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-daemon-embeddable/1.4.21/kotlin-daemon-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.4.21/kotlin-reflect-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-common/1.4.21/kotlin-scripting-common-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.4.21/kotlin-scripting-compiler-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler-impl-embeddable/1.4.21/kotlin-scripting-compiler-impl-embeddable-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jsr223/1.4.21/kotlin-scripting-jsr223-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm/1.4.21/kotlin-scripting-jvm-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm-host/1.4.21/kotlin-scripting-jvm-host-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-script-runtime/1.4.21/kotlin-script-runtime-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.4.21/kotlin-stdlib-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.21/kotlin-stdlib-common-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.4.21/kotlin-stdlib-jdk7-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.4.21/kotlin-stdlib-jdk8-1.4.21.jar
$HOME/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.3.7/kotlinx-coroutines-core-1.3.7.jar
$HOME/.m2/repository/org/scijava/parsington/2.0.0/parsington-2.0.0.jar
$HOME/.m2/repository/org/scijava/scijava-common/2.83.3/scijava-common-2.83.3.jar
$HOME/.m2/repository/org/scijava/scijava-common/2.83.3/scijava-common-2.83.3-tests.jar
$HOME/workspace/imklib/scripting-kotlin/target/classes/
$HOME/workspace/imklib/scripting-kotlin/target/test-classes/
and fails with
JUnit version 4.13
.E..E
Time: 0.798
There were 2 failures:
1) test basic engine eval with bindings(org.scijava.plugins.scripting.kotlin.KotlinTest)
javax.script.ScriptException: Unable to initialize repl compiler:
ERROR com/intellij/openapi/util/SystemInfo: java.lang.NoClassDefFoundError: com/intellij/openapi/util/SystemInfo
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.asJsr223EvalResult(KotlinJsr223JvmScriptEngineBase.kt:104)
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.compileAndEval(KotlinJsr223JvmScriptEngineBase.kt:63)
at kotlin.script.experimental.jvmhost.jsr223.KotlinJsr223ScriptEngineImpl.compileAndEval(KotlinJsr223ScriptEngineImpl.kt:94)
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.eval(KotlinJsr223JvmScriptEngineBase.kt:31)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at org.scijava.plugins.scripting.kotlin.KotlinScriptLanguage$SynchronizedScriptEngine.eval(KotlinScriptLanguage.kt:71)
at org.scijava.plugins.scripting.kotlin.KotlinScriptLanguage$SynchronizedScriptEngine.eval(KotlinScriptLanguage.kt:71)
at org.scijava.plugins.scripting.kotlin.KotlinScriptLanguage$SynchronizedScriptEngine.eval(KotlinScriptLanguage.kt:71)
at org.scijava.plugins.scripting.kotlin.KotlinTest.test basic engine eval with bindings(KotlinTest.kt:73)
2) test basic script engine eval(org.scijava.plugins.scripting.kotlin.KotlinTest)
javax.script.ScriptException: Unable to initialize repl compiler:
ERROR com/intellij/openapi/util/SystemInfo: java.lang.NoClassDefFoundError: com/intellij/openapi/util/SystemInfo
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.asJsr223EvalResult(KotlinJsr223JvmScriptEngineBase.kt:104)
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.compileAndEval(KotlinJsr223JvmScriptEngineBase.kt:63)
at kotlin.script.experimental.jvmhost.jsr223.KotlinJsr223ScriptEngineImpl.compileAndEval(KotlinJsr223ScriptEngineImpl.kt:94)
at org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineBase.eval(KotlinJsr223JvmScriptEngineBase.kt:31)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at org.scijava.plugins.scripting.kotlin.KotlinScriptLanguage$SynchronizedScriptEngine.eval(KotlinScriptLanguage.kt:71)
at org.scijava.plugins.scripting.kotlin.KotlinScriptLanguage$SynchronizedScriptEngine.eval(KotlinScriptLanguage.kt:71)
at org.scijava.plugins.scripting.kotlin.KotlinScriptLanguage$SynchronizedScriptEngine.eval(KotlinScriptLanguage.kt:71)
at org.scijava.plugins.scripting.kotlin.KotlinTest.test basic script engine eval(KotlinTest.kt:65)
FAILURES!!!
Tests run: 3, Failures: 2
Different error but I wonder if it goes back to the same root cause.
Update2: Strangely, when I replace -jar $HOME/workspace/imklib/scripting-kotlin/target/surefire/surefirebooter8529160978234802859.jar
above with the unsorted classpath and main class (both obtained from that same surefirebooter
jar), I don’t get any errors either. I wonder if there is an issue in how the jar is consumed by Java.