programing

"히카리풀-1 연결 클로저" java.lang.NoClassDefFoundError: org/mariadb/jdbc/message/client/QuitPacket

javamemo 2023. 7. 29. 08:06
반응형

"히카리풀-1 연결 클로저" java.lang.NoClassDefFoundError: org/mariadb/jdbc/message/client/QuitPacket

저는 지금 이 예외로 인해 꽤 오랫동안 어려움을 겪고 있습니다.

프록시 및 백엔드 플러그인에 사용되는 일반적인 항목을 관리하는 클래스가 있는 Java 프로그램(TG-Toolkit)이 있습니다.주요 용도 중 하나는 데이터베이스입니다.저는 마리아DB 콤보와 함께 HikariCP를 사용합니다.모든 것이 정상적으로 작동하지만 때때로(다시 시작하는 경우의 30% 정도) 이 예외가 발생합니다.그 후에도 여전히 모든 것이 정상적으로 작동하며, 말씀드린 것처럼 가끔만 예외가 발생합니다.

MariaDB 버전 3.1.4 HikariCP 버전 5.0.1

연결 및 결과 집합을 처리하기 위해 리소스 사용 시도를 사용

[12:05:27] [Server thread/INFO]: [Core] [STDOUT] BEFORE CLOSE
[12:05:27] [Server thread/WARN]: Nag author(s): '[Wega]' of 'Core' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
[12:05:27] [Server thread/WARN]: [Toolkit] HikariCP activity connections: 0
[12:05:27] [Server thread/INFO]: [com.zaxxer.hikari.HikariDataSource] HikariPool-1 - Shutdown initiated...
[12:05:27] [HikariPool-1 connection closer/WARN]: Exception in thread "HikariPool-1 connection closer" Exception in thread "HikariPool-1 connection closer" java.lang.NoClassDefFoundError: org/mariadb/jdbc/message/client/QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.client.impl.StandardClient.close(StandardClient.java:1003)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.Connection.close(Connection.java:235)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:137)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:444)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.lang.Thread.run(Thread.java:833)
[12:05:27] [HikariPool-1 connection closer/WARN]: Caused by: java.lang.ClassNotFoundException: org.mariadb.jdbc.message.client.QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     ... 7 more
[12:05:27] [HikariPool-1 connection closer/WARN]: Exception in thread "HikariPool-1 connection closer" Exception in thread "HikariPool-1 connection closer" java.lang.NoClassDefFoundError: org/mariadb/jdbc/message/client/QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.client.impl.StandardClient.close(StandardClient.java:1003)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.Connection.close(Connection.java:235)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:137)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:444)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.lang.Thread.run(Thread.java:833)
[12:05:27] [HikariPool-1 connection closer/WARN]: Caused by: java.lang.ClassNotFoundException: org.mariadb.jdbc.message.client.QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     ... 7 more
[12:05:27] [HikariPool-1 connection closer/WARN]: Exception in thread "HikariPool-1 connection closer" java.lang.NoClassDefFoundError: org/mariadb/jdbc/message/client/QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.client.impl.StandardClient.close(StandardClient.java:1003)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.Connection.close(Connection.java:235)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:137)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:444)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.lang.Thread.run(Thread.java:833)
[12:05:27] [HikariPool-1 connection closer/WARN]: Caused by: java.lang.ClassNotFoundException: org.mariadb.jdbc.message.client.QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     ... 7 more
[12:05:27] [HikariPool-1 connection closer/WARN]: Exception in thread "HikariPool-1 connection closer" Exception in thread "HikariPool-1 connection closer" java.lang.NoClassDefFoundError: org/mariadb/jdbc/message/client/QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.client.impl.StandardClient.close(StandardClient.java:1003)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.Connection.close(Connection.java:235)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:137)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:444)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.lang.Thread.run(Thread.java:833)
[12:05:27] [HikariPool-1 connection closer/WARN]: Caused by: java.lang.ClassNotFoundException: org.mariadb.jdbc.message.client.QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     ... 7 more
[12:05:27] [HikariPool-1 connection closer/WARN]: java.lang.NoClassDefFoundError: org/mariadb/jdbc/message/client/QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.client.impl.StandardClient.close(StandardClient.java:1003)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.Connection.close(Connection.java:235)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:137)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:444)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.lang.Thread.run(Thread.java:833)
[12:05:27] [HikariPool-1 connection closer/WARN]: Caused by: java.lang.ClassNotFoundException: org.mariadb.jdbc.message.client.QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:177)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:124)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
[12:05:27] [HikariPool-1 connection closer/WARN]:     ... 7 more
[12:05:27] [HikariPool-1 connection closer/WARN]: java.lang.NoClassDefFoundError: org/mariadb/jdbc/message/client/QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.client.impl.StandardClient.close(StandardClient.java:1003)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.Connection.close(Connection.java:235)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:137)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:444)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.lang.Thread.run(Thread.java:833)
[12:05:27] [HikariPool-1 connection closer/WARN]: Caused by: java.lang.ClassNotFoundException: org.mariadb.jdbc.message.client.QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     ... 7 more
[12:05:27] [HikariPool-1 connection closer/WARN]: Exception in thread "HikariPool-1 connection closer" java.lang.NoClassDefFoundError: org/mariadb/jdbc/message/client/QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.client.impl.StandardClient.close(StandardClient.java:1003)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.Connection.close(Connection.java:235)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:137)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:444)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[12:05:27] [Server thread/INFO]: [com.zaxxer.hikari.HikariDataSource] HikariPool-1 - Shutdown completed.
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.lang.Thread.run(Thread.java:833)
[12:05:27] [HikariPool-1 connection closer/WARN]: Caused by: java.lang.ClassNotFoundException: org.mariadb.jdbc.message.client.QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     ... 7 more
[12:05:27] [HikariPool-1 connection closer/WARN]: java.lang.NoClassDefFoundError: org/mariadb/jdbc/message/client/QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.client.impl.StandardClient.close(StandardClient.java:1003)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//org.mariadb.jdbc.Connection.close(Connection.java:235)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:137)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at core-0.2-SNAPSHOT.jar//com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:444)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[12:05:27] [HikariPool-1 connection closer/WARN]:     at java.base/java.lang.Thread.run(Thread.java:833)
[12:05:27] [HikariPool-1 connection closer/WARN]: Caused by: java.lang.ClassNotFoundException: org.mariadb.jdbc.message.client.QuitPacket
[12:05:27] [HikariPool-1 connection closer/WARN]:     ... 7 more
[code][12:05:27] [Server thread/INFO]: [Core] [STDOUT] AFTER CLOSE

사용하는 코드는 다음과 같습니다.

package net.trustgames.toolkit.managers;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import net.trustgames.toolkit.Toolkit;
import org.jetbrains.annotations.NotNull;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

/**
 * This class handles the basic MariaDB and HikariCP methods such as getting connection,
 * creating the database, table (if not exists) and closing the hikari connection. Note that the
 * plugin#getLogger is used instead of Bukkit#getLogger, because async methods should not access Bukkit API
 */
public final class HikariManager {

    private static final Logger logger = Toolkit.getLogger();
    private static HikariDataSource dataSource;

    /**
     * Sets parameters and creates new pool.
     * (is run async)
     */
    public HikariManager(@NotNull String user,
                         @NotNull String password,
                         @NotNull String ip,
                         @NotNull String port,
                         @NotNull String database,
                         @NotNull Integer poolSize) {
        HikariConfig hikariConfig = new HikariConfig();
        hikariConfig.setDriverClassName("org.mariadb.jdbc.Driver");
        hikariConfig.setJdbcUrl("jdbc:mariadb://" + ip + ":" + port + "/" + database);
        hikariConfig.addDataSourceProperty("user", user);
        hikariConfig.addDataSourceProperty("password", password);
        hikariConfig.setMaximumPoolSize(poolSize);

        dataSource = new HikariDataSource(hikariConfig);
    }

    /**
     * gets a new connection from the hikaricp pool
     */
    public Connection getConnection() {
        try {
            return dataSource.getConnection();
        } catch (SQLException e) {
            System.out.println("RUNTIME EXCEPTION 1");
            throw new RuntimeException("Getting a new connection from HikariCP", e);
        }
    }

    /**
     * @param callback When datasource is initialized
     */
    public void onDataSourceInitialized(Runnable callback) {
        CompletableFuture.runAsync(() -> {
                    if (dataSource != null) {
                        callback.run();
                    } else {
                        // if dataSource is null, schedule the callback to be run when it is initialized
                        try {
                            Thread.sleep(500L);
                            onDataSourceInitialized(callback);
                        } catch (InterruptedException e) {
                            System.out.println("RUNTIME EXCEPTION 10");
                            throw new RuntimeException(e);
                        }
                    }
                }).orTimeout(10L, TimeUnit.SECONDS)
                .exceptionally(throwable -> {
                    Toolkit.getLogger().severe("HikariCP data source initialization timed out!");
                    return null;
                });
    }

    /**
     * @return
     * true - if datasource is initialized<p>
     * false - if datasource is not initialized
     */
    public boolean isDataSourceInitialized() {
        return dataSource != null;
    }

    /**
     * checks if the table exists, if it doesn't, it creates one using the given SQL statement
     * (is run async)
     *
     * @param tableName       The name of the table
     * @param stringStatement The SQL statement in String
     */
    public void initializeTable(@NotNull String tableName, @NotNull String stringStatement) {
        CompletableFuture.runAsync(() -> {
            try (Connection connection = getConnection()) {
                try (PreparedStatement statement = connection.prepareStatement(stringStatement)) {
                    statement.executeUpdate();
                }
            } catch (SQLException e) {
                System.out.println("RUNTIME EXCEPTION 11");
                throw new RuntimeException("Unable to create missing " + tableName + " table in the database!", e);
            }
        });
    }

    public void close() {
        Toolkit.getLogger().warning("HikariCP activity connections: " + dataSource.getHikariPoolMXBean().getActiveConnections());
        dataSource.close();
    }
}

이것이 내 스피것 플러그인의 onDisable 메서드에서 풀을 닫는 방법입니다.

public void closeConnections() {
        if (hikariManager.isDataSourceInitialized())
            hikariManager.close();
}

github의 전체 코드에 대한 링크도 여기 있습니다.이와 관련해서는 안 되지만, 더 자세히 보고 싶은 사람이 있다면 제 손님이 되어 주십시오.https://github.com/ThomasWega/TG-Toolkit/ https://github.com/ThomasWega/TG-Core/

풀을 닫을 때 아직 열려 있는 연결이 남아 있을 수 있다고 생각하여 콘솔에 인쇄하고 있지만, spigot 서버 종료 시 0개의 연결이 활성 상태로 표시되므로 문제가 되지 않습니다.저는 또한 관련된 방법에 인쇄를 추가하려고 시도했지만, 거기서도 역시 실패했습니다.수영장을 폐쇄하는 것만으로도 정말 원인인 것 같은데, 이유는 알 수가 없습니다.

언급URL : https://stackoverflow.com/questions/76174455/hikaripool-1-connection-closer-java-lang-noclassdeffounderror-org-mariadb-jdb

반응형