Olaf Gottschalk
04/20/2023, 3:31 PMeval
on the script engine.
After the update to Kotlin 1.8.20 when my scripts contain String
operations such as
val x = "Hello"
x.uppercase()
I get this horrible exception:
error: cannot access '<http://java.io|java.io>.Serializable' which is a supertype of 'kotlin.String'. Check your module classpath for missing or conflicting dependencies
The point is: I did not change anything there. I am using good old JVM 11 (due to some 3rd party libs that are very slow to upgrade, thanks go out to to SAP and IBM)
Looking at the Gradle dependency tree reveals nothing out of the ordinary, every Kotlin dependency is at 1.8.20. I do not see any conflicts there. And of course, my static code compiles just fine, it is just the dynamic code compiled at runtime that now complains.
Does anybody have any hints for me on how to check & proceed?
THANKS!ilya.chernikov
04/24/2023, 10:08 AMOlaf Gottschalk
04/24/2023, 10:40 AMilya.chernikov
04/24/2023, 11:06 AMjava.home
system properties is not processed properly. I just need to understand which path is missing the action. So if you'll show me the relevant part of the stacktrace and/or the code that set up script compilation, I might already be able to guess the reason and maybe offer a workaround.ilya.chernikov
04/24/2023, 11:07 AMilya.chernikov
04/24/2023, 11:08 AMOlaf Gottschalk
04/24/2023, 11:30 AMOlaf Gottschalk
04/24/2023, 11:39 AMilya.chernikov
04/24/2023, 2:52 PM-jdk-home
to the compiler instead.
But how to do it, depends on how you're launching scripts.Olaf Gottschalk
04/24/2023, 3:05 PMilya.chernikov
04/24/2023, 3:16 PMOlaf Gottschalk
04/24/2023, 3:27 PMilya.chernikov
04/25/2023, 6:37 AMBasicJvmScriptingHost
or maybe something else?Olaf Gottschalk
04/25/2023, 2:39 PMilya.chernikov
04/26/2023, 2:41 PMkotlin-scripting-jsr223
jar, you may try to set experimental kotlin.jsr223.experimental.resolve.dependencies.from.context.classloader
system property to "true", before requesting an engine. It changes the way how the context dependencies are processed in the engine, and it may help.Olaf Gottschalk
04/26/2023, 3:21 PMilya.chernikov
04/27/2023, 10:07 AMOlaf Gottschalk
04/27/2023, 10:08 AMOlaf Gottschalk
05/02/2023, 2:54 PMkotlin-script-util
jar. In order to register this per config, I had a META-INF/services/javax.script.ScriptEngineFactory
file which references this engine factory.
Up until Kotlin 1.8.10 this obsolete engine factory still worked properly, so I in fact never noticed (nor knew) anything about it.
Since Kotlin 1.8.20 it should NOT be used anymore. The new implementation is automatically registered when depending on kotlin-scripting-compiler-embeddable
and kotlin-scripting-jsr233
.
So, removing the obsolete dependency and removing the META-INF
file solved my issue!
Thanks again, Ilya!ilya.chernikov
05/02/2023, 3:34 PMkotlin-script-util
should have been replaced with other APIs and jars quite long ago, but in 1.8.20 we accidentally broke it, and since it is long obsolete - have no intention to fix. We will remove it from publishing instead in one of the next versions.Christian Nedregaard
06/26/2023, 9:32 PMRuntimeException: Using JDK home inferred from java.home: /usr/lib/jvm/zulu11-ca-amd64
Using JVM IR backend
Using new faster version of JAR FS: it should make your build faster, but the new implementation is experimental
Loading modules: [<http://java.se|java.se>, com.azul.tooling, jdk.accessibility, jdk.attach, jdk.compiler, jdk.dynalink, jdk.httpserver, jdk.jartool, jdk.javadoc, jdk.jconsole, jdk.jdi, jdk.jfr, jdk.jshell, jdk.jsobject, jdk.management, jdk.management.jfr, jdk.naming.ldap, <http://jdk.net|jdk.net>, jdk.scripting.nashorn, jdk.sctp, jdk.security.auth, jdk.security.jgss, jdk.unsupported, jdk.unsupported.desktop, jdk.xml.dom, kotlin.stdlib, kotlin.script.runtime, kotlin.reflect, java.base, java.compiler, java.datatransfer, java.desktop, java.xml, java.instrument, java.logging, java.management, java.management.rmi, java.rmi, java.naming, java.net.http, java.prefs, java.scripting, java.security.jgss, java.security.sasl, java.sql, java.transaction.xa, java.sql.rowset, java.xml.crypto, jdk.internal.jvmstat, jdk.management.agent, jdk.jdwp.agent, jdk.internal.ed, jdk.internal.le, jdk.internal.opt]
Module kotlin.stdlib cannot be found in the module graph
Module kotlin.script.runtime cannot be found in the module graph
Module kotlin.reflect cannot be found in the module graph < CompletionException: java.lang.RuntimeException: Using JDK home inferred from java.home: /usr/lib/jvm/zulu11-ca-amd64
Using BasicJvmScriptingHost eval
with this compilation configuration:
createJvmCompilationConfigurationFromTemplate<SimpleScriptTemplate> {
jvm {
// unpackJarCollections = true will enable this to work when running from the Spring Boot fat jar.
dependenciesFromCurrentContext(wholeClasspath = true, unpackJarCollections = true)
}
}
...and this evaluation config with a custom filtering classloader:
createJvmEvaluationConfigurationFromTemplate<SimpleScriptTemplate> {
jvm {
baseClassLoader(filteringClassLoader)
}
}
I do not think kotlin-script-util
is involved here?
Any idea how to proceed?ilya.chernikov
06/27/2023, 6:25 AMmodule-info
files correctly, and that leads to the problems like this on the module-based JDKs (9+).Christian Nedregaard
06/27/2023, 6:32 AMChristian Nedregaard
07/25/2023, 8:47 AMIstván Mészáros
01/26/2024, 2:55 PMLoading modules: [myproject, java.base]
Loading modules: [java.base]
Unresolved reference: sql
Unresolved reference: Timestamp
Unresolved reference: Timestamp
Cannot access class 'java.sql.Timestamp'. Check your module classpath for missing or conflicting dependencies
And then lots of lots of similar messages are coming. I guess the problem is that only "myproject" and "java.base" is loaded and "java.sql" for example is missing.
Does anyone have an idea to fix this? Project works perfectly when running from IDEA or when it is deployed as separate JAR files.