Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

插件注册类引入外部依赖导致加载失败 #2189

Closed
RimuruChan opened this issue Aug 8, 2022 · 2 comments
Closed

插件注册类引入外部依赖导致加载失败 #2189

RimuruChan opened this issue Aug 8, 2022 · 2 comments
Labels
z:duplicate 状态: 重复

Comments

@RimuruChan
Copy link

RimuruChan commented Aug 8, 2022

问题描述

在插件的注册类使用运行时加载的依赖会导致NoClassDefFoundError并退出

复现

在插件注册类使用第三方依赖并通过dependencies-private.txt导入

mirai-core 版本

2.12.1

bot-protocol

ANDROID_PHONE

其他组件版本

mirai-console 2.12.1

系统日志

2022-08-08 16:17:20 E/main: Failed to init MiraiConsole.
net.mamoe.mirai.console.internal.util.ServiceLoadException: Could not load service tech.rimuruchan.ChatSync.
        at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadService(PluginServiceHelper.kt:60)
        at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadAllServices(PluginServiceHelper.kt:42)
        at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl$extractPlugins$findAllInstances$2.invoke(BuiltInJvmPluginLoaderImpl.kt:170)
        at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl$extractPlugins$findAllInstances$2.invoke(BuiltInJvmPluginLoaderImpl.kt:165)
        at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
        at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:314)
        at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:303)
        at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214)
        at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214)
        at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:316)
        at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:303)
        at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:786)
        at kotlin.sequences.SequencesKt___SequencesKt.toSet(_Sequences.kt:827)
        at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.extractPlugins(BuiltInJvmPluginLoaderImpl.kt:191)
        at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.listPlugins(BuiltInJvmPluginLoaderImpl.kt:66)
        at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.listPlugins(JvmPluginLoader.kt)
        at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.listAndSortAllPlugins(PluginManagerImpl.kt:192)
        at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.findAndSortAllPluginsUsingBuiltInLoaders(PluginManagerImpl.kt:138)
        at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.loadAllPluginsUsingBuiltInLoaders$mirai_console(PluginManagerImpl.kt:148)
        at net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge.doStart$mirai_console(MiraiConsoleImplementationBridge.kt:178)
        at net.mamoe.mirai.console.MiraiConsoleImplementation$Companion.start(MiraiConsoleImplementation.kt:464)
        at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon(MiraiConsoleTerminalLoader.kt:168)
        at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon$default(MiraiConsoleTerminalLoader.kt:167)
        at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.main(MiraiConsoleTerminalLoader.kt:52)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.itxtech.mcl.Utility.bootJars(Utility.java:89)
        at org.itxtech.mcl.Utility.bootJars(Utility.java:79)
        at org.itxtech.mcl.Utility.bootMirai(Utility.java:101)
        at org.itxtech.mcl.module.builtin.Boot.boot(Boot.java:109)
        at org.itxtech.mcl.module.ModuleManager.phaseBoot(ModuleManager.java:148)
        at org.itxtech.mcl.Loader.lambda$start$4(Loader.java:189)
        at org.itxtech.mcl.Loader.tryCatching(Loader.java:146)
        at org.itxtech.mcl.Loader.start(Loader.java:189)
        at org.itxtech.mcl.Loader.main(Loader.java:79)
Caused by: java.lang.NoClassDefFoundError: org/telegram/telegrambots/meta/exceptions/TelegramApiException
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:467)
        at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadService(PluginServiceHelper.kt:51)
        ... 36 more
Caused by: java.lang.ClassNotFoundException: org.telegram.telegrambots.meta.exceptions.TelegramApiException
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        at net.mamoe.mirai.console.internal.plugin.JvmPluginClassLoaderN.loadClass(JvmPluginClassLoader.kt:389)
        ... 39 more

网络日志

No response

补充信息

No response

@cssxsh
Copy link
Contributor

cssxsh commented Aug 8, 2022

以目前的加载流程,
使用maven库 需要 在 onLoad / onEnable 方法 里 初始化, <init> 阶段还无法初始化maven库的类

@Karlatemp
Copy link
Member

#1985

@Karlatemp Karlatemp added the z:duplicate 状态: 重复 label Aug 8, 2022
@Karlatemp Karlatemp closed this as not planned Won't fix, can't repro, duplicate, stale Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
z:duplicate 状态: 重复
Projects
None yet
Development

No branches or pull requests

3 participants