Maven Tests with ScriptEngine run in IntelliJ but fail on command line

I am working on a project to include Kotlin as a language in a script interpreter in a Java GUI. I am working on a branch to fix the Kotlin engine and I can import the Kotlin engine into the GUI and interpret Kotlin as expected. The tests run successfully in IntelliJ IDEA. On the command line (mvn test), however, the tests fail with:

[ERROR] test basic script engine eval(org.scijava.plugins.scripting.kotlin.KotlinTest)  Time elapsed: 0.442 s  <<< 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
        at org.scijava.plugins.scripting.kotlin.KotlinTest.test basic script engine eval(KotlinTest.kt:64)

This happens both with Kotlin 1.4.10 and 1.4.21. The contents of pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>org.scijava</groupId>
		<artifactId>pom-scijava</artifactId>
		<version>29.2.1</version>
		<relativePath />
	</parent>

	<artifactId>scripting-kotlin</artifactId>
	<version>0.1.2-SNAPSHOT</version>

	<name>SciJava Scripting: Kotlin</name>
	<description>JSR-223-compliant Kotlin scripting language plugin.</description>
	<url>https://github.com/scijava/scripting-kotlin</url>
	<inceptionYear>2016</inceptionYear>
	<organization>
		<name>SciJava</name>
		<url>https://scijava.org/</url>
	</organization>
	<licenses>
		<license>
			<name>Simplified BSD License</name>
			<distribution>repo</distribution>
		</license>
	</licenses>

	<developers>
		<developer>
			<id>ctrueden</id>
			<name>Curtis Rueden</name>
			<url>https://imagej.net/User:Rueden</url>
			<roles>
				<role>founder</role>
				<role>lead</role>
				<role>developer</role>
				<role>debugger</role>
				<role>reviewer</role>
				<role>support</role>
				<role>maintainer</role>
			</roles>
		</developer>
	</developers>
	<contributors>
		<contributor>
			<name>Philipp Hanslovsky</name>
			<url>https://imagej.net/User:Hanslovsky</url>
			<properties><id>hanslovsky</id></properties>
		</contributor>
	</contributors>

	<mailingLists>
		<mailingList>
			<name>SciJava</name>
			<subscribe>https://groups.google.com/group/scijava</subscribe>
			<unsubscribe>https://groups.google.com/group/scijava</unsubscribe>
			<post>scijava.com</post>
			<archive>https://groups.google.com/group/scijava</archive>
		</mailingList>
	</mailingLists>

	<scm>
		<connection>scm:git:git://github.com/scijava/scripting-kotlin</connection>
		<developerConnection>scm:git:git@github.com:scijava/scripting-kotlin</developerConnection>
		<tag>HEAD</tag>
		<url>https://github.com/scijava/scripting-kotlin</url>
	</scm>
	<issueManagement>
		<system>GitHub Issues</system>
		<url>https://github.com/scijava/scripting-kotlin/issues</url>
	</issueManagement>
	<ciManagement>
		<system>Travis CI</system>
		<url>https://travis-ci.org/scijava/scripting-kotlin</url>
	</ciManagement>

	<properties>
		<package-name>org.scijava.plugins.scripting.kotlin</package-name>
		<license.licenseName>bsd_2</license.licenseName>
		<license.copyrightOwners>Board of Regents of the University of
Wisconsin-Madison.</license.copyrightOwners>

		<!-- NB: Deploy releases to the SciJava Maven repository. -->
		<releaseProfiles>deploy-to-scijava</releaseProfiles>

		<!-- NB: Work around duplicate classes issue in Kotlin dependencies-->
		<allowedDuplicateClasses>org/jetbrains/kotlin/daemon/common/*,kotlinx/coroutines/**</allowedDuplicateClasses>
		<kotlin.version>1.4.21</kotlin.version>
	</properties>

	<repositories>
		<repository>
			<id>scijava.public</id>
			<url>https://maven.scijava.org/content/groups/public/</url>
		</repository>
	</repositories>

	<dependencies>
		<!-- SciJava dependencies -->
		<dependency>
			<groupId>org.scijava</groupId>
			<artifactId>scijava-common</artifactId>
		</dependency>

		<!-- Kotlin dependencies -->
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-compiler-embeddable</artifactId>
			<version>${kotlin.version}</version>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-stdlib</artifactId>
			<version>${kotlin.version}</version>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-scripting-jsr223</artifactId>
			<version>${kotlin.version}</version>
		</dependency>

		<!-- Test dependencies -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.scijava</groupId>
			<artifactId>scijava-common</artifactId>
			<classifier>tests</classifier>
			<scope>test</scope>
		</dependency>
	</dependencies>
</project>

and the maven dependency tree:

--- maven-dependency-plugin:3.1.2:tree (default-cli) @ scripting-kotlin ---
org.scijava:scripting-kotlin:jar:0.1.2-SNAPSHOT
+- org.scijava:scijava-common:jar:2.83.3:compile
|  +- org.scijava:parsington:jar:2.0.0:compile
|  \- org.bushe:eventbus:jar:1.4:compile
+- org.jetbrains.kotlin:kotlin-compiler-embeddable:jar:1.4.21:compile
|  +- org.jetbrains.kotlin:kotlin-script-runtime:jar:1.4.21:runtime
|  +- org.jetbrains.kotlin:kotlin-reflect:jar:1.4.21:runtime
|  +- org.jetbrains.kotlin:kotlin-daemon-embeddable:jar:1.4.21:runtime
|  \- org.jetbrains.intellij.deps:trove4j:jar:1.0.20181211:runtime
+- org.jetbrains.kotlin:kotlin-stdlib:jar:1.4.21:compile
|  +- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.4.21:compile
|  \- org.jetbrains:annotations:jar:13.0:compile
+- org.jetbrains.kotlin:kotlin-scripting-jsr223:jar:1.4.21:compile
|  +- org.jetbrains.kotlin:kotlin-scripting-common:jar:1.4.21:runtime
|  |  \- org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:1.3.7:runtime
|  +- org.jetbrains.kotlin:kotlin-scripting-jvm:jar:1.4.21:runtime
|  +- org.jetbrains.kotlin:kotlin-scripting-jvm-host:jar:1.4.21:runtime
|  \- org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:jar:1.4.21:runtime
|     \- org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:jar:1.4.21:runtime
+- junit:junit:jar:4.13:test
|  \- org.hamcrest:hamcrest-core:jar:1.3:test
+- org.scijava:scijava-common:jar:tests:2.83.3:test
\- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.4.21:compile
   \- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.4.21:compile

Relevant links:

Any help appreciated!

1 Like

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.

2 Likes