I have a Java app that supports external scripting via JSR 223 API. I’m currently using Groovy as the main scripting language but I want to add Kotlin as well. I dropped in (what I believe) all the required Kotlin libraries into the app, the app finds and instantiates the Kotlin ScriptEngine and can run simple scripts (e.g., print(“Hello”)) However, when I try to pass objects as script arguments or use other Java classes in the script I get the following error:
“Cannot access script provided property class ‘mypackage.MyClass’. Check your module classpath for missing or conflicting dependencies”
Unresolved reference: myotherpackage
The same app runs the same script fine, if I start it from the IDE (Intellij). It’s only when I run the compiled jar from the command line, things break down. It feels like there is an issues where Kotlin fails to find the classes. I checked the current thread’s ClassLoader before instantiating the ScriptEngine and the ClassLoader seems fine to me – it knows about all the classes including ‘mypackage.MyClass’ and ‘myotherpackage.*’
I’d appreciate any help or suggestions. Thank you.
Here are the files I include with the app to get the script engine to load.