Недавно я обновил версию java от java 1.7 до java 1.8. После обновления я получаю эту ошибку.Nashorn - Не удается найти общий загрузчик классов для ScriptObject и MyInterface
Вызвано: ECMAScript Исключение: Тип Ошибка: не удается найти общий загрузчик классов для ScriptObject и My Interface.
Пожалуйста, помогите мне исправить эту проблему.
Ниже мой метод
private final ScriptEngine engine;
ScriptEngineManager sem = new ScriptEngineManager();
engine = sem.getEngineByName("nashorn");
public <K> K getNewInterface(MyScript myScript){
ScriptContext ctx = new SimpleScriptContext();
String script = myScript.getScript();
if(Strings.isEmpty(script)) {markInvalid(myScript, "Script is empty", null); return null;}
script += " (function(){return this;})();";
Object thiz;
try{
thiz = engine.eval(script, ctx);
} catch (ScriptException e){
markInvalid(myScript, "Can't execute script", e);
return null;
}
if(thiz==null) {markInvalid(myScript, "Script executed, but context is null", null); return null;}
K ret = (K) ((Invocable)engine).getInterface(thiz, myScript.getScriptInterfaceClass());
if(ret==null) {
markInvalid(myScript, "Script executed, but it's incompatible with required interface", null);
return null;
}else{
myScript.setValid(true);
return ret;
}
}
спасибо за ваш ответ Аттилы. Я сделал так, как вам было предложено, и получил ClassNotFoundException java.lang.ClassNotFoundException: jdk.nashorn.internal.runtime.ScriptObject из [Module "deployment.dep.war: main" из Service Module Loader] – Bhagat