Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javax.script.ScriptException: Unable to initialize repl compiler #10

Open
jayvdb opened this issue Feb 18, 2023 · 1 comment
Open

javax.script.ScriptException: Unable to initialize repl compiler #10

jayvdb opened this issue Feb 18, 2023 · 1 comment

Comments

@jayvdb
Copy link

jayvdb commented Feb 18, 2023

I dont have a kotlin/kotlinc intentionally, and would like to use jgo to fetch that on demand. See also scijava/jgo#89

When I try the instructions given at scijava/scijava-common#451 (comment) , I get an error:

$ jgo --repository scijava.public=https://maven.scijava.org/content/groups/public  org.scijava:scijava-common:2.90.3-SNAPSHOT:@ScriptCLI+org.scijava:scripting-kotlin path/to/script.kt
..
[ERROR] javax.script.ScriptException: Unable to initialize repl compiler:
  ERROR java.lang.ExceptionInInitializerError: java.lang.ExceptionInInitializerError
	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 java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262)
	at org.scijava.plugins.scripting.kotlin.KotlinScriptLanguage$SynchronizedScriptEngine.eval(KotlinScriptLanguage.kt:70)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:173)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:163)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

That appears to be coming from here : https://github.com/JetBrains/kotlin/blob/a4ce2ced6d22086da756242ea114183dc702feab/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/repl/KotlinJsr223JvmScriptEngineBase.kt#L104

This happens even if I explicitly add more of the kotlin jars to the jgo cli, like so:

$ jgo --repository scijava.public=https://maven.scijava.org/content/groups/public --additional-endpoints org.jetbrains.kotlin:kotlin-stdlib org.jetbrains.kotlin:kotlin-compiler  org.scijava:scijava-common:2.90.3-SNAPSHOT:@ScriptCLI+org.scijava:scripting-kotlin path/to/script.kt

I am wondering if scripting-kotlin might be able to somehow assist with this, possibly by doing the compile first, using https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-compiler-embeddable ?

@jayvdb
Copy link
Author

jayvdb commented Dec 30, 2023

I am able to get it working with

jgo --log-level=DEBUG --repository scijava.public=https://maven.scijava.org/content/groups/public --additional-endpoints org.jetbrains.kotlin:kotlin-scripting-jvm-host org.scijava:scijava-common:@ScriptREPL+org.scijava:scripting-kotlin 

Should https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-scripting-jvm-host be added as a dependency?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant