simple-robot / simpler-robot

Simple Robot,一个bot风格的Kotlin多平台事件调度框架,异步高效、Java友好!/ A Bot-style Kotlin Multiplatform event scheduling framework, asynchronous and high-performance, java-friendly! 🐱😼😻😸
https://simbot.forte.love
GNU Lesser General Public License v3.0
512 stars 44 forks source link

java.lang.ClassNotFoundException: kotlin.time.DurationUnit #552

Closed Enderman-Teleporting closed 1 year ago

Enderman-Teleporting commented 1 year ago

版本号

v3.0.0

附加版本

No response

问题描述

成功springboot打包.但提示缺失依赖 见下

复现方式

`package simbot.example;

import love.forte.simboot.annotation.Listener; import love.forte.simboot.core.SimbootApp; import love.forte.simboot.core.SimbootApplication; import love.forte.simbot.event.internal.BotRegisteredEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import simbot.example.tools.properties_settler;

@SimbootApplication public class Main {

private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);

public static void main(String[] args) {
    final var context = SimbootApp.run(Main.class, args);
    context.launchBlocking();
    properties_settler.settle();
}

@Listener
public void botRegistered(BotRegisteredEvent botRegisteredEvent) {
    LOGGER.info("Bot({}) 注册成功!", botRegisteredEvent.getBot());
}

} ` 启动类,demo直接拉的,但是报错,据日志应为第18行即context.launchBlocking()那行

相关日志

C:\Windows\Java\jdk17\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2022.1.4\lib\idea_rt.jar=8845:C:\Program Files\JetBrains\IntelliJ IDEA 2022.1.4\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\wyh\Documents\GitHub\QBot_v3\target\classes;C:\Users\wyh\.m2\repository\love\forte\simbot\boot\simboot-core\3.0.0-M5\simboot-core-3.0.0-M5.jar;C:\Users\wyh\.m2\repository\love\forte\simbot\simbot-logger-jvm\3.0.0-M5\simbot-logger-jvm-3.0.0-M5.jar;C:\Users\wyh\.m2\repository\org\jetbrains\kotlin\kotlin-stdlib-common\1.7.20\kotlin-stdlib-common-1.7.20.jar;C:\Users\wyh\.m2\repository\love\forte\simbot\boot\simboot-api\3.0.0-M5\simboot-api-3.0.0-M5.jar;C:\Users\wyh\.m2\repository\love\forte\simbot\simbot-core\3.0.0-M5\simbot-core-3.0.0-M5.jar;C:\Users\wyh\.m2\repository\love\forte\simbot\simbot-api\3.0.0-M5\simbot-api-3.0.0-M5.jar;C:\Users\wyh\.m2\repository\love\forte\di\di-api\0.0.3\di-api-0.0.3.jar;C:\Users\wyh\.m2\repository\org\jetbrains\kotlinx\kotlinx-coroutines-jdk8\1.6.4\kotlinx-coroutines-jdk8-1.6.4.jar;C:\Users\wyh\.m2\repository\love\forte\simbot\boot\simboot-core-annotation\3.0.0-M5\simboot-core-annotation-3.0.0-M5.jar;C:\Users\wyh\.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;C:\Users\wyh\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\wyh\.m2\repository\org\jetbrains\kotlinx\kotlinx-coroutines-core-jvm\1.6.4\kotlinx-coroutines-core-jvm-1.6.4.jar;C:\Users\wyh\.m2\repository\org\jetbrains\kotlinx\kotlinx-serialization-core-jvm\1.4.0\kotlinx-serialization-core-jvm-1.4.0.jar;C:\Users\wyh\.m2\repository\org\jetbrains\kotlinx\kotlinx-serialization-json-jvm\1.4.0\kotlinx-serialization-json-jvm-1.4.0.jar;C:\Users\wyh\.m2\repository\love\forte\di\di-core\0.0.3\di-core-0.0.3.jar;C:\Users\wyh\.m2\repository\org\jetbrains\kotlin\kotlin-reflect\1.6.0\kotlin-reflect-1.6.0.jar;C:\Users\wyh\.m2\repository\love\forte\annotation-tool\kcore\0.6.3\kcore-0.6.3.jar;C:\Users\wyh\.m2\repository\love\forte\annotation-tool\api\0.6.3\api-0.6.3.jar;C:\Users\wyh\.m2\repository\org\jetbrains\kotlin\kotlin-stdlib-jdk8\1.7.20\kotlin-stdlib-jdk8-1.7.20.jar;C:\Users\wyh\.m2\repository\org\jetbrains\kotlin\kotlin-stdlib-jdk7\1.7.20\kotlin-stdlib-jdk7-1.7.20.jar;C:\Users\wyh\.m2\repository\love\forte\simbot\component\simbot-component-mirai-core\3.0.0.0-beta.6\simbot-component-mirai-core-3.0.0.0-beta.6.jar;C:\Users\wyh\.m2\repository\net\mamoe\mirai-core-jvm\2.13.2\mirai-core-jvm-2.13.2.jar;C:\Users\wyh\.m2\repository\net\mamoe\mirai-core-api-jvm\2.13.2\mirai-core-api-jvm-2.13.2.jar;C:\Users\wyh\.m2\repository\net\mamoe\mirai-console-compiler-annotations-jvm\2.13.2\mirai-console-compiler-annotations-jvm-2.13.2.jar;C:\Users\wyh\.m2\repository\org\bouncycastle\bcprov-jdk15on\1.64\bcprov-jdk15on-1.64.jar;C:\Users\wyh\.m2\repository\me\him188\kotlin-jvm-blocking-bridge-runtime-jvm\2.1.0-170.1\kotlin-jvm-blocking-bridge-runtime-jvm-2.1.0-170.1.jar;C:\Users\wyh\.m2\repository\me\him188\kotlin-dynamic-delegation-jvm\0.3.0-170.1\kotlin-dynamic-delegation-jvm-0.3.0-170.1.jar;C:\Users\wyh\.m2\repository\net\mamoe\mirai-core-utils-jvm\2.13.2\mirai-core-utils-jvm-2.13.2.jar;C:\Users\wyh\.m2\repository\org\jetbrains\kotlinx\kotlinx-serialization-protobuf-jvm\1.3.3\kotlinx-serialization-protobuf-jvm-1.3.3.jar;C:\Users\wyh\.m2\repository\org\jetbrains\kotlinx\atomicfu-jvm\0.18.3\atomicfu-jvm-0.18.3.jar;C:\Users\wyh\.m2\repository\org\apache\logging\log4j\log4j-api\2.17.2\log4j-api-2.17.2.jar;C:\Users\wyh\.m2\repository\io\netty\netty-all\4.1.63.Final\netty-all-4.1.63.Final.jar;C:\Users\wyh\.m2\repository\love\forte\catcode\1.0.0-BETA.1\catcode-1.0.0-BETA.1.jar;C:\Users\wyh\.m2\repository\org\jetbrains\kotlin\kotlin-stdlib\1.4.30-M1\kotlin-stdlib-1.4.30-M1.jar;C:\Users\wyh\.m2\repository\org\jetbrains\annotations\13.0\annotations-13.0.jar;C:\Users\wyh\.m2\repository\net\sf\json-lib\json-lib\2.1\json-lib-2.1-jdk15.jar;C:\Users\wyh\.m2\repository\commons-beanutils\commons-beanutils\1.7.0\commons-beanutils-1.7.0.jar;C:\Users\wyh\.m2\repository\commons-collections\commons-collections\3.1\commons-collections-3.1.jar;C:\Users\wyh\.m2\repository\commons-lang\commons-lang\2.5\commons-lang-2.5.jar;C:\Users\wyh\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\wyh\.m2\repository\net\sf\ezmorph\ezmorph\1.0.3\ezmorph-1.0.3.jar simbot.example.Main
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/time/DurationUnit
    at love.forte.simbot.utils.SuspendRunner.<clinit>(BlockingRunner.kt:587)
    at love.forte.simbot.utils.DefaultRunInNoScopeBlockingStrategy.invoke(BlockingRunner.kt:397)
    at love.forte.simbot.utils.BlockingRunnerKt.runInNoScopeBlocking(BlockingRunner.kt:462)
    at love.forte.simbot.utils.BlockingRunnerKt.runInNoScopeBlocking$default(BlockingRunner.kt:459)
    at love.forte.simbot.utils.BlockingRunnerKt.$$runInBlocking(BlockingRunner.kt:503)
    at love.forte.simbot.application.ApplicationLauncher.launchBlocking(ApplicationLauncher.kt)
    at simbot.example.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException: kotlin.time.DurationUnit
    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)
    ... 7 more

进程已结束,退出代码1

其他补充

No response

ForteScarlet commented 1 year ago

参考 https://github.com/orgs/simple-robot/discussions/17

Enderman-Teleporting commented 1 year ago

并未重复引入咳特灵 具体配制见下

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>simbot.example</groupId>
    <artifactId>simbot-boot-normal-java</artifactId>
    <version>0</version>

    <properties>
        <java.version>17</java.version>
        <simbot.version>3.0.0-M5</simbot.version>
        <simbot-mirai.version>3.0.0.0-beta.6</simbot-mirai.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>love.forte.simbot.boot</groupId>
            <artifactId>simboot-core</artifactId>
            <version>${simbot.version}</version>
        </dependency>

        <dependency>
            <groupId>love.forte.simbot.component</groupId>
            <artifactId>simbot-component-mirai-core</artifactId>
            <version>${simbot-mirai.version}</version>
        </dependency>
        <dependency>
            <groupId>love.forte</groupId>
            <artifactId>catcode</artifactId>
            <version>1.0.0-BETA.1</version>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.1</version>
            <classifier>jdk15</classifier>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.7.0</version>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/net.sf.ezmorph/ezmorph -->
        <dependency>
        <groupId>net.sf.ezmorph</groupId>
        <artifactId>ezmorph</artifactId>
        <version>1.0.3</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <!-- main方法所在类。 -->
                    <mainClass>simbot.example.Main</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
ForteScarlet commented 1 year ago

自行检查各依赖中是否存在不同版本的Kotlin引用并排除它们,例如 catcode 使用的是大约 v1.4.x 的Kotlin。

Enderman-Teleporting commented 1 year ago

删除了依赖:CatCode 其他应该都是用Java写的 错误日志:(powershell)

Windows PowerShell
版权所有(C) Microsoft Corporation。保留所有权利。

安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows

PS C:\Users\wyh> cd desktop
PS C:\Users\wyh\desktop> java -jar qbot.jar
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
java.io.IOException: 系统找不到指定的路径。
        at java.base/java.io.WinNTFileSystem.createFileExclusively(Native Method)
        at java.base/java.io.File.createNewFile(File.java:1043)
        at simbot.example.tools.properties_settler.settle(properties_settler.java:12)
        at simbot.example.Main.main(Main.java:19)
        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.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
PS C:\Users\wyh\desktop>
ForteScarlet commented 1 year ago

kotlin.time.DurationUnit 类丢失问题似乎已经解决。 此问题与框架无关,请自行检查相关代码