iTXTech / mirai-js

强大的 Mirai JavaScript 插件运行时
GNU Affero General Public License v3.0
86 stars 33 forks source link

调用http.get的时候报错Can't find method org.itxtech.miraijs.libs.KotlinCoroutineLib$DeferredJsImpl.await() #14

Open HYLZ-2019 opened 2 years ago

HYLZ-2019 commented 2 years ago

我的代码: 1662654721704

运行时报错:

2022-09-09 00:20:12 W/Bot.(群号): An exception occurred when processing event. Subscriber scope: '<unnamed>'. Broadcaster scope: 'Bot(群号).EventDispatcher'
org.mozilla.javascript.EvaluatorException: Can't find method org.itxtech.miraijs.libs.KotlinCoroutineLib$DeferredJsImpl.await(). (importOkHttpLib#63)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:79)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.Context.reportRuntimeError(Context.java:972)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.Context.reportRuntimeError(Context.java:1025)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.Context.reportRuntimeError1(Context.java:988)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:145)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1692)
        at script(importOkHttpLib:63)
        at script(importOkHttpLib:19)
        at script(sfapu.library#main:48)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1013)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:412)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3578)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:107)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.ArrowFunction.call(ArrowFunction.java:43)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.InterfaceAdapter.invokeImpl(InterfaceAdapter.java:155)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.InterfaceAdapter.lambda$invoke$0(InterfaceAdapter.java:105)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.Context.call(Context.java:554)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.ContextFactory.call(ContextFactory.java:522)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.InterfaceAdapter.invoke(InterfaceAdapter.java:105)
        at mirai-js-2.0-RC-dev2.mirai.jar//org.mozilla.javascript.jdk18.VMBridge_jdk18$1.invoke(VMBridge_jdk18.java:126)
        at jdk.proxy1/jdk.proxy1.$Proxy25.accept(Unknown Source)
        at net.mamoe.mirai.event.EventChannel$subscribeAlways$2$1.invoke(EventChannel.kt:631)
        at net.mamoe.mirai.event.EventChannel$subscribeAlways$2$1.invoke(EventChannel.kt:631)
        at kotlinx.coroutines.InterruptibleKt.runInterruptibleInExpectedContext(Interruptible.kt:51)
        at kotlinx.coroutines.InterruptibleKt.access$runInterruptibleInExpectedContext(Interruptible.kt:1)
        at kotlinx.coroutines.InterruptibleKt$runInterruptible$2.invokeSuspend(Interruptible.kt:43)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

请大佬赐教orz

StageGuard commented 2 years ago

你的环境?

HYLZ-2019 commented 2 years ago

Mirai, 使用./mcl启动,config.json如下:

{
  "module_packages": [
    "mcl:org.itxtech.mcl.module.builtin"
  ],
  "mirai_repo": "https://repo.itxtech.org",
  "maven_repo": [
    "https://maven.aliyun.com/repository/public"
  ],
  "packages": {
    "net.mamoe:mirai-console": {
      "channel": "stable",
      "version": "2.12.1",
      "type": "libs",
      "versionLocked": false
    },
    "net.mamoe:mirai-console-terminal": {
      "channel": "stable",
      "version": "2.12.1",
      "type": "libs",
      "versionLocked": false
    },
    "net.mamoe:mirai-core-all": {
      "channel": "stable",
      "version": "2.12.1",
      "type": "libs",
      "versionLocked": false
    },
    "org.itxtech:mcl-addon": {
      "channel": "c2001",
      "version": "2.0.2",
      "type": "plugins",
      "versionLocked": false
    },
    "net.mamoe:mirai-api-http": {
      "channel": "stable-v2","version": "2.5.2",
      "type": "plugins",
      "versionLocked": false
    },
    "net.mamoe:chat-command": {
      "channel": "stable",
      "version": "0.5.1",
      "type": "plugins",
      "versionLocked": false
    }
  },
  "archiveSuffix": [
    ".zip",
    ".mirai2.jar",
    ".mirai.jar",
    "-all.jar",
    ".jar"
  ],
  "disabled_modules": [],
  "proxy": "",
  "log_level": 1,
  "modules_props": {}
}
StageGuard commented 2 years ago

不推荐使用 mcl 启动。 https://github.com/iTXTech/mirai-js#mirai-console-loader-%E5%85%BC%E5%AE%B9%E6%80%A7

HYLZ-2019 commented 2 years ago

使用:

java -cp "./libs/*" net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader

启动后,仍然报错:

2022-09-09 01:11:03 W/Bot.(群号): An exception occurred when processing event. Subscriber scope: '<unnamed>'. Broadcaster scope: 'Bot (群号).EventDispatcher'
org.mozilla.javascript.EvaluatorException: Can't find method org.itxtech.miraijs.libs.KotlinCoroutineLib$DeferredJsImpl.await(). (importOkHttpLib#63)

Java版本:

openjdk 11.0.16 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu118.04)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu118.04, mixed mode, sharing)

(睡觉去也,明天再回复,感谢您的帮助)