gpt4 book ai didi

java-8 - 最新的 JDK 8 Build 40 从 Nashorn 引擎返回间歇性异常

转载 作者:行者123 更新时间:2023-11-30 03:36:38 25 4
gpt4 key购买 nike

我安装了新的 JDK 1.8 build: 40,现在我从有效的 javascript 函数中间歇性收到以下异常,有什么想法吗?

java version "1.8.0_40-ea"
Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b19)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b23, mixed mode)

异常(exception):

.....
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.script.ScriptException: TypeError: function __noSuchMethod__() { [native code] } is not a constructor function in <eval> at line number 21
at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:455)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:439)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:401)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:397)
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:152)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at com.nube.portal.engines.js.JsEngine.eval(JsEngine.java:101)
... 74 more

Caused by: <eval>:21 TypeError: function __noSuchMethod__() { [native code] } is not a constructor function
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172)
at jdk.nashorn.internal.runtime.ScriptFunctionData.getBestConstructor(ScriptFunctionData.java:239)
at jdk.nashorn.internal.runtime.ScriptFunction.findNewMethod(ScriptFunction.java:474)
at jdk.nashorn.internal.runtime.ScriptObject.lookup(ScriptObject.java:1874)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:100)
at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:94)
at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:149)
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:233)
at jdk.nashorn.internal.scripts.Script$Recompilation$9$134AAA$\^eval\_.L:6$http(<eval>:21)
at jdk.nashorn.internal.scripts.Script$Recompilation$8$977AA$\^eval\_.L:6$get(<eval>:41)
at jdk.nashorn.internal.scripts.Script$7$\^eval\_.:program(<eval>:1)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:437)
... 79 more

代码:此实用程序将有助于调用休息服务电话。

(function (global, factory) {

factory(global.Rest = {});

}(this, function (rest) {

rest.http = function(url, request, method) {

method = (method == null?"GET":method);

if(request != undefined){
for (var key in request) {
if (request.hasOwnProperty(key)) {
url = url + key+"="+request[key] +"&";
}
}
}

with (new JavaImporter(java.io, java.net)) {
var is = new URL(url).openConnection();
try {
is.setRequestProperty("Content-Type", "application/json");
is.setRequestMethod(method);
var reader = new BufferedReader(
new InputStreamReader(is.getInputStream()));
var buf = '', line = null;
while ((line = reader.readLine()) != null) {
buf += line;
}
} finally {
reader.close();
}
return buf;
}
};

rest.get = function(url, request){
return JSON.parse(rest.http(url, request, "GET"));
};

}));

现在我正在使用 Rest.get() 进行服务调用

var result = Rest.get("http://someurl?...");

此调用在一段时间内工作正常,并在一段时间后开始抛出异常。

最佳答案

我也遇到了同样的问题。

这可能是 JavaImporter 的错误。

我通过不使用 JavaImpoter 解决了这个问题。

关于java-8 - 最新的 JDK 8 Build 40 从 Nashorn 引擎返回间歇性异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27751754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com