Invocable.getInterface fails across classloaders in web app
Максим Гумеров
mgumerov at gmail.com
Tue Jul 28 18:53:57 UTC 2015
Regarding those two advices.
>> 1) set the thread context class loader to be whichever loader that can
"see" those classes in question.
As I wrote in my question, I could probably do that, but extension loader
(or bootstrap loader) will not see my application's JAR. So I will not be
able to load my Composer with this loader. So I have to load it with
app-level class loader.
>> 2) Using nashorn specific API - NashornScriptEngineFactory class and
directly pass a classloader (to be the "application loader" for nashorn)
while creating engine.
Unfortunately this did not work as well (with exactly the same error
message). I can only suppose that this overload of getScriptEngine() does
not use the passed classloader to load Nashorn's ScriptObject (might be,
it's even guaranteed that ScriptObject class is already loaded at that
moment), but instead only uses the passed classloader when JavaScript
execution needs to load some Java class.
More information about the nashorn-dev
mailing list