[Вопрос] HikariCP

Psycho

Жнец
Модератор
Сообщения
4 768
Розыгрыши
1
Решения
3
Репутация
4 398
Реакции
3 186
Баллы
2 543
Хроники
  1. Chaotic Throne: High Five
  2. Grand Cursade
Исходники
Присутствуют
Сборка
L2JUnity
Пытаюсь переделать DatabaseFactory.java.
По дефолту юнити юзают c3p0, я же хочу использовать hikari, но не могу одуплить последние пару строк.
Java:
/**
* Gets the busy connection count.
* @return the busy connection count
* @throws SQLException the SQL exception
*/
public int getBusyConnectionCount() throws SQLException
{
return _source.getNumBusyConnectionsDefaultUser();
}

/**
* Gets the idle connection count.
* @return the idle connection count
* @throws SQLException the SQL exception
*/
public int getIdleConnectionCount() throws SQLException
{
return _source.getNumIdleConnectionsDefaultUser();
}
Java:
/*
* Copyright (C) 2004-2015 L2J Unity
*
* This file is part of L2J Unity.
*
* L2J Unity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Unity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2junity.commons.sql;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.concurrent.TimeUnit;

import org.l2junity.commons.util.concurrent.ThreadPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mchange.v2.c3p0.ComboPooledDataSource;

/**
* This class manages the database connections.
*/
public final class DatabaseFactory
{
    private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseFactory.class);

    private static DatabaseFactory _instance;
    private ComboPooledDataSource _source;

    private IDatabaseConfig _databaseConfig = null;

    protected DatabaseFactory()
    {
        // visibility
    }

    public void setDatabaseConfig(IDatabaseConfig config)
    {
        _databaseConfig = config;
    }

    public void init() throws SQLException
    {
        if (_databaseConfig == null)
        {
            throw new NullPointerException("Database Config is not specified!");
        }
 
        try
        {
            // Sorry, no noob support. If you really want that crap, use ConfigLoader#loadImpl(PropertiesParser, PropertiesParser)
            // if (_databaseConfig.getMaxConnections() < 2) { _databaseConfig.getMaxConnections() = 2; LOGGER.warn("A minimum of {} db connections are required.", _databaseConfig.getMaxConnections()); }
     
            _source = new ComboPooledDataSource();
            _source.setAutoCommitOnClose(true);
     
            _source.setInitialPoolSize(10);
            _source.setMinPoolSize(10);
            _source.setMaxPoolSize(Math.max(10, _databaseConfig.getMaxConnections()));
     
            _source.setAcquireRetryAttempts(0); // try to obtain connections indefinitely (0 = never quit)
            _source.setAcquireRetryDelay(500); // 500 milliseconds wait before try to acquire connection again
            _source.setCheckoutTimeout(0); // 0 = wait indefinitely for new connection
            // if pool is exhausted
            _source.setAcquireIncrement(5); // if pool is exhausted, get 5 more connections at a time
            // cause there is a "long" delay on acquire connection
            // so taking more than one connection at once will make connection pooling
            // more effective.
     
            _source.setIdleConnectionTestPeriod(3600); // test idle connection every 60 sec
            _source.setMaxIdleTime(_databaseConfig.getMaxIdleTime()); // 0 = idle connections never expire
            // *THANKS* to connection testing configured above
            // but I prefer to disconnect all connections not used
            // for more than 1 hour
     
            // enables statement caching, there is a "semi-bug" in c3p0 0.9.0 but in 0.9.0.2 and later it's fixed
            _source.setMaxStatementsPerConnection(100);
     
            _source.setBreakAfterAcquireFailure(false); // never fail if any way possible
            // setting this to true will make
            // c3p0 "crash" and refuse to work
            // till restart thus making acquire
            // errors "FATAL" ... we don't want that
            // it should be possible to recover
            _source.setJdbcUrl(_databaseConfig.getJdbcURL());
            _source.setUser(_databaseConfig.getUsername());
            _source.setPassword(_databaseConfig.getPassword());
     
            /* Test the connection */
            _source.getConnection().close();
        }
        catch (SQLException x)
        {
            // re-throw the exception
            throw x;
        }
        catch (Exception e)
        {
            throw new SQLException("Could not init DB connection:" + e.getMessage());
        }
 
        LOGGER.info("Initialized DB '{}' as user '{}'.", _databaseConfig.getJdbcURL(), _databaseConfig.getUsername());
    }

    private void closeSource()
    {
        if (_source != null)
        {
            _source.close();
        }
 
        // Is this really necessary?
        _source = null;
    }

    /**
     * Shutdown.
     */
    public static void shutdown()
    {
        if (_instance == null)
        {
            return;
        }
 
        LOGGER.info("Shutting down.");
 
        try
        {
            DatabaseFactory.getInstance().closeSource();
        }
        catch (Exception e)
        {
            LOGGER.warn("", e);
        }
    }

    /**
     * Gets the single instance of L2DatabaseFactory.
     * @return single instance of L2DatabaseFactory
     */
    public static DatabaseFactory getInstance()
    {
        synchronized (DatabaseFactory.class)
        {
            if (_instance == null)
            {
                _instance = new DatabaseFactory();
            }
        }
        return _instance;
    }

    /**
     * Gets the connection.
     * @return the connection
     */
    public Connection getConnection()
    {
        Connection con = null;
        while (con == null)
        {
            try
            {
                con = _source.getConnection();
         
                ThreadPool.schedule(new ConnectionCloser(con, new RuntimeException()), _databaseConfig.getConnectionCloseTime(), TimeUnit.MILLISECONDS);
            }
            catch (SQLException e)
            {
                LOGGER.warn("getConnection() failed, trying again", e);
            }
        }
        return con;
    }

    /**
     * The Class ConnectionCloser.
     */
    private static final class ConnectionCloser implements Runnable
    {
        private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionCloser.class);
 
        /** The connection. */
        private final Connection c;
 
        /** The exception. */
        private final RuntimeException exp;
 
        /**
         * Instantiates a new connection closer.
         * @param con the con
         * @param e the e
         */
        public ConnectionCloser(Connection con, RuntimeException e)
        {
            c = con;
            exp = e;
        }
 
        @Override
        public void run()
        {
            try
            {
                if (!c.isClosed())
                {
                    LOGGER.warn("Unclosed connection! Trace: {}", exp.getStackTrace()[1], exp);
                }
            }
            catch (SQLException e)
            {
                LOGGER.warn("", e);
            }
        }
    }

    /**
     * Gets the busy connection count.
     * @return the busy connection count
     * @throws SQLException the SQL exception
     */
    public int getBusyConnectionCount() throws SQLException
    {
        return _source.getNumBusyConnectionsDefaultUser();
    }

    /**
     * Gets the idle connection count.
     * @return the idle connection count
     * @throws SQLException the SQL exception
     */
    public int getIdleConnectionCount() throws SQLException
    {
        return _source.getNumIdleConnectionsDefaultUser();
    }
}
Java:
package l2j.commons.sql;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.concurrent.TimeUnit;

import l2j.commons.util.concurrent.ThreadPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.zaxxer.hikari.HikariDataSource;

/**
* This class manages the database connections.
*/
public final class DatabaseFactory
{
    private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseFactory.class);

    private static DatabaseFactory _instance;
    private HikariDataSource _source;

    private IDatabaseConfig _databaseConfig = null;

    protected DatabaseFactory()
    {
        // visibility
    }

    public void setDatabaseConfig(IDatabaseConfig config)
    {
        _databaseConfig = config;
    }

    public void init() throws SQLException
    {
        if (_databaseConfig == null)
        {
            throw new NullPointerException("Database Config is not specified!");
        }
 
        try
        {
            _source = new HikariDataSource();
            _source.setAutoCommit(true);
            _source.setJdbcUrl(_databaseConfig.getJdbcURL());
            _source.setUsername(_databaseConfig.getUsername());
            _source.setPassword(_databaseConfig.getPassword());
            _source.setMaximumPoolSize(Math.max(10, _databaseConfig.getMaxConnections()));
            _source.getIdleTimeout(_databaseConfig.getIdleTimeout());

     
            /* Test the connection */
            _source.getConnection().close();
        }
        catch (SQLException x)
        {
            // re-throw the exception
            throw x;
        }
        catch (Exception e)
        {
            throw new SQLException("Could not init DB connection:" + e.getMessage());
        }
 
        LOGGER.info("Initialized DB '{}' as user '{}'.", _databaseConfig.getJdbcURL(), _databaseConfig.getUsername());
    }

    private void closeSource()
    {
        if (_source != null)
        {
            _source.close();
        }
 
        // Is this really necessary?
        _source = null;
    }

    /**
     * Shutdown.
     */
    public static void shutdown()
    {
        if (_instance == null)
        {
            return;
        }
 
        LOGGER.info("Shutting down.");
 
        try
        {
            DatabaseFactory.getInstance().closeSource();
        }
        catch (Exception e)
        {
            LOGGER.warn("", e);
        }
    }

    /**
     * Gets the single instance of L2DatabaseFactory.
     * @return single instance of L2DatabaseFactory
     */
    public static DatabaseFactory getInstance()
    {
        synchronized (DatabaseFactory.class)
        {
            if (_instance == null)
            {
                _instance = new DatabaseFactory();
            }
        }
        return _instance;
    }

    /**
     * Gets the connection.
     * @return the connection
     */
    public Connection getConnection()
    {
        Connection con = null;
        while (con == null)
        {
            try
            {
                con = _source.getConnection();
         
                ThreadPool.schedule(new ConnectionCloser(con, new RuntimeException()), _databaseConfig.getConnectionCloseTime(), TimeUnit.MILLISECONDS);
            }
            catch (SQLException e)
            {
                LOGGER.warn("getConnection() failed, trying again", e);
            }
        }
        return con;
    }

    /**
     * The Class ConnectionCloser.
     */
    private static final class ConnectionCloser implements Runnable
    {
        private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionCloser.class);
 
        /** The connection. */
        private final Connection c;
 
        /** The exception. */
        private final RuntimeException exp;
 
        /**
         * Instantiates a new connection closer.
         * @param con the con
         * @param e the e
         */
        public ConnectionCloser(Connection con, RuntimeException e)
        {
            c = con;
            exp = e;
        }
 
        @Override
        public void run()
        {
            try
            {
                if (!c.isClosed())
                {
                    LOGGER.warn("Unclosed connection! Trace: {}", exp.getStackTrace()[1], exp);
                }
            }
            catch (SQLException e)
            {
                LOGGER.warn("", e);
            }
        }
    }

    /**
     * Gets the busy connection count.
     * @return the busy connection count
     * @throws SQLException the SQL exception
     */
    public int getBusyConnectionCount() throws SQLException
    {
        return _source.getNumBusyConnectionsDefaultUser();
    }

    /**
     * Gets the idle connection count.
     * @return the idle connection count
     * @throws SQLException the SQL exception
     */
    public int getIdleConnectionCount() throws SQLException
    {
        return _source.getNumIdleConnectionsDefaultUser();
    }
}
Java:
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.zaxxer.hikari;

import com.zaxxer.hikari.metrics.MetricsTrackerFactory;
import com.zaxxer.hikari.pool.HikariPool;
import com.zaxxer.hikari.pool.HikariPool.PoolInitializationException;
import java.io.Closeable;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HikariDataSource extends HikariConfig implements DataSource, Closeable {
    private static final Logger LOGGER = LoggerFactory.getLogger(HikariDataSource.class);
    private final AtomicBoolean isShutdown = new AtomicBoolean();
    private final HikariPool fastPathPool;
    private volatile HikariPool pool;

    public HikariDataSource() {
        this.fastPathPool = null;
    }

    public HikariDataSource(HikariConfig configuration) {
        configuration.validate();
        configuration.copyStateTo(this);
        LOGGER.info("{} - Starting...", configuration.getPoolName());
        this.pool = this.fastPathPool = new HikariPool(this);
        LOGGER.info("{} - Start completed.", configuration.getPoolName());
        this.seal();
    }

    public Connection getConnection() throws SQLException {
        if (this.isClosed()) {
            throw new SQLException("HikariDataSource " + this + " has been closed.");
        } else if (this.fastPathPool != null) {
            return this.fastPathPool.getConnection();
        } else {
            HikariPool result = this.pool;
            if (result == null) {
                synchronized(this) {
                    result = this.pool;
                    if (result == null) {
                        this.validate();
                        LOGGER.info("{} - Starting...", this.getPoolName());

                        try {
                            this.pool = result = new HikariPool(this);
                            this.seal();
                        } catch (PoolInitializationException var5) {
                            if (var5.getCause() instanceof SQLException) {
                                throw (SQLException)var5.getCause();
                            }

                            throw var5;
                        }

                        LOGGER.info("{} - Start completed.", this.getPoolName());
                    }
                }
            }

            return result.getConnection();
        }
    }

    public Connection getConnection(String username, String password) throws SQLException {
        throw new SQLFeatureNotSupportedException();
    }

    public PrintWriter getLogWriter() throws SQLException {
        HikariPool p = this.pool;
        return p != null ? p.getUnwrappedDataSource().getLogWriter() : null;
    }

    public void setLogWriter(PrintWriter out) throws SQLException {
        HikariPool p = this.pool;
        if (p != null) {
            p.getUnwrappedDataSource().setLogWriter(out);
        }

    }

    public void setLoginTimeout(int seconds) throws SQLException {
        HikariPool p = this.pool;
        if (p != null) {
            p.getUnwrappedDataSource().setLoginTimeout(seconds);
        }

    }

    public int getLoginTimeout() throws SQLException {
        HikariPool p = this.pool;
        return p != null ? p.getUnwrappedDataSource().getLoginTimeout() : 0;
    }

    public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
        throw new SQLFeatureNotSupportedException();
    }

    public <T> T unwrap(Class<T> iface) throws SQLException {
        if (iface.isInstance(this)) {
            return this;
        } else {
            HikariPool p = this.pool;
            if (p != null) {
                DataSource unwrappedDataSource = p.getUnwrappedDataSource();
                if (iface.isInstance(unwrappedDataSource)) {
                    return unwrappedDataSource;
                }

                if (unwrappedDataSource != null) {
                    return unwrappedDataSource.unwrap(iface);
                }
            }

            throw new SQLException("Wrapped DataSource is not an instance of " + iface);
        }
    }

    public boolean isWrapperFor(Class<?> iface) throws SQLException {
        if (iface.isInstance(this)) {
            return true;
        } else {
            HikariPool p = this.pool;
            if (p != null) {
                DataSource unwrappedDataSource = p.getUnwrappedDataSource();
                if (iface.isInstance(unwrappedDataSource)) {
                    return true;
                }

                if (unwrappedDataSource != null) {
                    return unwrappedDataSource.isWrapperFor(iface);
                }
            }

            return false;
        }
    }

    public void setMetricRegistry(Object metricRegistry) {
        boolean isAlreadySet = this.getMetricRegistry() != null;
        super.setMetricRegistry(metricRegistry);
        HikariPool p = this.pool;
        if (p != null) {
            if (isAlreadySet) {
                throw new IllegalStateException("MetricRegistry can only be set one time");
            }

            p.setMetricRegistry(super.getMetricRegistry());
        }

    }

    public void setMetricsTrackerFactory(MetricsTrackerFactory metricsTrackerFactory) {
        boolean isAlreadySet = this.getMetricsTrackerFactory() != null;
        super.setMetricsTrackerFactory(metricsTrackerFactory);
        HikariPool p = this.pool;
        if (p != null) {
            if (isAlreadySet) {
                throw new IllegalStateException("MetricsTrackerFactory can only be set one time");
            }

            p.setMetricsTrackerFactory(super.getMetricsTrackerFactory());
        }

    }

    public void setHealthCheckRegistry(Object healthCheckRegistry) {
        boolean isAlreadySet = this.getHealthCheckRegistry() != null;
        super.setHealthCheckRegistry(healthCheckRegistry);
        HikariPool p = this.pool;
        if (p != null) {
            if (isAlreadySet) {
                throw new IllegalStateException("HealthCheckRegistry can only be set one time");
            }

            p.setHealthCheckRegistry(super.getHealthCheckRegistry());
        }

    }

    public boolean isRunning() {
        return this.pool != null && this.pool.poolState == 0;
    }

    public HikariPoolMXBean getHikariPoolMXBean() {
        return this.pool;
    }

    public HikariConfigMXBean getHikariConfigMXBean() {
        return this;
    }

    public void evictConnection(Connection connection) {
        HikariPool p;
        if (!this.isClosed() && (p = this.pool) != null && connection.getClass().getName().startsWith("com.zaxxer.hikari")) {
            p.evictConnection(connection);
        }

    }

    public void close() {
        if (!this.isShutdown.getAndSet(true)) {
            HikariPool p = this.pool;
            if (p != null) {
                try {
                    LOGGER.info("{} - Shutdown initiated...", this.getPoolName());
                    p.shutdown();
                    LOGGER.info("{} - Shutdown completed.", this.getPoolName());
                } catch (InterruptedException var3) {
                    LOGGER.warn("{} - Interrupted during closing", this.getPoolName(), var3);
                    Thread.currentThread().interrupt();
                }
            }

        }
    }

    public boolean isClosed() {
        return this.isShutdown.get();
    }

    public String toString() {
        return "HikariDataSource (" + this.pool + ")";
    }
}
Подскажите, на что последние пару строк менять?
На что нужно заменить эти строки, чтобы затарахтело? Ничего подобного не нашел в hikari.
з.ы. На счет _source.getIdleTimeout(_databaseConfig.getIdleTimeout()); не уверен.
Возможно нужно будет указать так: _source.getIdleTimeout(0);
 
Последнее редактирование:
Запускается всё что угодно, кроме этих сурсов. Хотя и их год назад запускал.




Смотри прикол, он мне после каждого билда в сурсах создает конфиги. В них пасс к бд прописал, и с горем пополам запускает. Что за херня? Почему он из дистов не берет конфиги, а билдит их в сурсы?
Код:
"C:\Program Files\Java\JDK\bin\java.exe" "-javaagent:C:\Program Files\IntelliJ IDEA\lib\idea_rt.jar=52173:C:\Program Files\IntelliJ IDEA\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\JDK\jre\lib\charsets.jar;C:\Program Files\Java\JDK\jre\lib\deploy.jar;C:\Program Files\Java\JDK\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\JDK\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\JDK\jre\lib\ext\dnsns.jar;C:\Program Files\Java\JDK\jre\lib\ext\jaccess.jar;C:\Program Files\Java\JDK\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\JDK\jre\lib\ext\localedata.jar;C:\Program Files\Java\JDK\jre\lib\ext\nashorn.jar;C:\Program Files\Java\JDK\jre\lib\ext\sunec.jar;C:\Program Files\Java\JDK\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\JDK\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\JDK\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\JDK\jre\lib\ext\zipfs.jar;C:\Program Files\Java\JDK\jre\lib\javaws.jar;C:\Program Files\Java\JDK\jre\lib\jce.jar;C:\Program Files\Java\JDK\jre\lib\jfr.jar;C:\Program Files\Java\JDK\jre\lib\jfxswt.jar;C:\Program Files\Java\JDK\jre\lib\jsse.jar;C:\Program Files\Java\JDK\jre\lib\management-agent.jar;C:\Program Files\Java\JDK\jre\lib\plugin.jar;C:\Program Files\Java\JDK\jre\lib\resources.jar;C:\Program Files\Java\JDK\jre\lib\rt.jar;D:\Project\production\java;D:\Project\dist\libs\server.jar;D:\Project\dist\libs\guava-21.0.jar;D:\Project\dist\libs\c3p0-0.9.1.2.jar;D:\Project\dist\libs\weupnp-0.1.4.jar;D:\Project\dist\libs\slf4j-api-1.7.25.jar;D:\Project\dist\libs\slf4j-simple-1.7.25.jar;D:\Project\dist\libs\javax.mail-api-1.5.6.jar;D:\Project\dist\libs\netty-all-4.1.28.Final.jar;D:\Project\dist\libs\mariadb-java-client-2.3.0.jar;D:\Project\production\dist" l2j.loginserver.L2LoginServer
[main] INFO l2j.commons.util.CommonUtil - ------------------------------------------------------------------------------------------------------=[ Configuration ]
[main] INFO l2j.commons.config.ConfigManager - Loaded 3 config file(s).
[main] INFO l2j.commons.util.CommonUtil - ------------------------------------------------------------------------------------------------------=[ Shutdown Hook ]
[main] INFO l2j.commons.lang.management.ShutdownManager - Initialized.
[main] INFO l2j.commons.util.CommonUtil - --------------------------------------------------------------------------------------------------=[ Deadlock Detector ]
[main] INFO l2j.commons.lang.management.DeadlockDetector - Disabled.
[main] INFO l2j.commons.util.CommonUtil - -----------------------------------------------------------------------------------------------------=[ Thread Pool(s) ]
[main] INFO l2j.commons.util.concurrent.ThreadPool - Initialized with
[main] INFO l2j.commons.util.concurrent.ThreadPool -     ... 4/4 scheduled thread(s).
[main] INFO l2j.commons.util.concurrent.ThreadPool -     ... 4/4 thread(s).
[main] INFO l2j.commons.util.CommonUtil - -----------------------------------------------------------------------------------------------------------=[ Database ]
апр 17, 2019 1:25:33 PM com.mchange.v2.log.MLog <clinit>
INFO: MLog clients using java 1.4+ standard logging.
апр 17, 2019 1:25:34 PM com.mchange.v2.c3p0.C3P0Registry banner
INFO: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
апр 17, 2019 1:25:34 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 5, acquireRetryAttempts -> 0, acquireRetryDelay -> 500, autoCommitOnClose -> true, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge14za2bvtibs1v579kh|6108b2d7, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> null, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge14za2bvtibs1v579kh|6108b2d7, idleConnectionTestPeriod -> 3600, initialPoolSize -> 10, jdbcUrl -> jdbc:mysql://localhost/l2j?useSSL=false&serverTimezone=Europe/Moscow, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 10, maxStatements -> 0, maxStatementsPerConnection -> 100, minPoolSize -> 10, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
[main] INFO l2j.commons.sql.DatabaseFactory - Initialized DB 'jdbc:mysql://localhost/l2j?useSSL=false&serverTimezone=Europe/Moscow' as user 'root'.
[main] INFO l2j.commons.util.CommonUtil - --------------------------------------------------------------------------------------------------------=[ Application ]
[main] INFO l2j.commons.util.CommonUtil - ------------------------------------------------------------------------------------------------------------=[ Manager ]
[main] INFO l2j.loginserver.LoginController - Loading LoginController...
[main] INFO l2j.loginserver.LoginController - Cached 10 KeyPairs for RSA communication
[main] INFO l2j.loginserver.LoginController - Stored 20 keys for Blowfish communication
[main] INFO l2j.loginserver.GameServerTable - Loaded 1 registered Game Servers
[main] INFO l2j.loginserver.GameServerTable - Cached 10 RSA keys for Game Server communication.
[main] WARN l2j.commons.util.IXmlReader - Could not parse file: data\servername.xml
java.io.FileNotFoundException: D:\Project\java\data\servername.xml (Системе не удается найти указанный путь)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:623)
    at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:148)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:806)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
    at l2j.commons.util.IXmlReader.parseFile(IXmlReader.java:102)
    at l2j.loginserver.ILoginXmlReader.parseDatapackFile(ILoginXmlReader.java:26)
    at l2j.loginserver.GameServerTable.load(GameServerTable.java:67)
    at l2j.loginserver.GameServerTable.<init>(GameServerTable.java:56)
    at l2j.loginserver.GameServerTable$SingletonHolder.<clinit>(GameServerTable.java:675)
    at l2j.loginserver.GameServerTable.getInstance(GameServerTable.java:667)
    at l2j.loginserver.L2LoginServer.<init>(L2LoginServer.java:73)
    at l2j.loginserver.L2LoginServer.main(L2LoginServer.java:46)
[main] WARN l2j.loginserver.GameServerTable - Failed to load server names
l2j.commons.util.XmlReaderException: java.io.FileNotFoundException: D:\Project\java\data\servername.xml (Системе не удается найти указанный путь)
    at l2j.commons.util.IXmlReader.parseFile(IXmlReader.java:112)
    at l2j.loginserver.ILoginXmlReader.parseDatapackFile(ILoginXmlReader.java:26)
    at l2j.loginserver.GameServerTable.load(GameServerTable.java:67)
    at l2j.loginserver.GameServerTable.<init>(GameServerTable.java:56)
    at l2j.loginserver.GameServerTable$SingletonHolder.<clinit>(GameServerTable.java:675)
    at l2j.loginserver.GameServerTable.getInstance(GameServerTable.java:667)
    at l2j.loginserver.L2LoginServer.<init>(L2LoginServer.java:73)
    at l2j.loginserver.L2LoginServer.main(L2LoginServer.java:46)
Caused by: java.io.FileNotFoundException: D:\Project\java\data\servername.xml (Системе не удается найти указанный путь)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:623)
    at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:148)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:806)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
    at l2j.commons.util.IXmlReader.parseFile(IXmlReader.java:102)
    ... 7 more
[main] WARN l2j.loginserver.L2LoginServer - IP Bans file (banned_ip.cfg) is missing or is a directory, skipped.
[main] INFO l2j.loginserver.L2LoginServer - Listening for GameServers on 127.0.0.1:9014
[main] INFO l2j.loginserver.L2LoginServer - L2LoginServer: is now listening on: *:2106
[main] INFO l2j.commons.util.CommonUtil - ---------------------------------------------------------------------------------------------------------------=[ UPnP ]
[main] INFO l2j.commons.network.UPnPService - UPnP is disabled.
[main] INFO l2j.commons.util.CommonUtil - ----------------------------------------------------------------------------------------------=[ Execution Environment ]
[main] INFO l2j.commons.util.AppInit - Version Info - IDE Mode.
[main] INFO l2j.commons.util.AppInit - Version Info - IDE Mode.
[main] INFO l2j.commons.util.AppInit - Version Info - IDE Mode.
[main] INFO l2j.commons.util.CommonUtil - ------------------------------------------------------------------------------------------------------=[ Memory (Heap) ]
[main] INFO l2j.commons.util.AppInit - GC done in 54 milliseconds, 636 microseconds, 809 nanoseconds.
[main] INFO l2j.commons.util.AppInit - +----
[main] INFO l2j.commons.util.AppInit - | Global Memory Information at 13:25:35:
[main] INFO l2j.commons.util.AppInit - |    |
[main] INFO l2j.commons.util.AppInit - | Allowed Memory: 1,8 GB
[main] INFO l2j.commons.util.AppInit - |    |= Allocated Memory: 220,5 MB (12,20%)
[main] INFO l2j.commons.util.AppInit - |    |= Non-Allocated Memory: 1,6 GB (87,80%)
[main] INFO l2j.commons.util.AppInit - | Allocated Memory: 220,5 MB
[main] INFO l2j.commons.util.AppInit - |    |= Used Memory: 10,0 MB (0,55%)
[main] INFO l2j.commons.util.AppInit - |    |= Unused (cached) Memory: 210,5 MB (11,64%)
[main] INFO l2j.commons.util.AppInit - | Useable Memory: 1,8 GB (99,45%)
[main] INFO l2j.commons.util.AppInit - +----
[main] INFO l2j.commons.util.CommonUtil - ------------------------------------------------------------------------------------------------------------=[ Summary ]
[main] INFO l2j.commons.util.AppInit - Initialized in 3 seconds, 36 milliseconds.
[main] INFO l2j.commons.util.CommonUtil - -----------------------------------------------------------------------------------------------------=[ ApplicationLog ]
 
Последнее редактирование:
Видишь где он Файлы ищет: java.io.FileNotFoundException: D:\Project\java\data\servername.xml (Системе не удается найти указанный путь)
А у тебя модули по другому разбросаны.
Тебе надо видимо отдельные модули для гейма и логина сделать(разделить src папку) и внутри них ресурсы руками добавить соответственно в таком же виде, как у тебя после внешнего билдера они располагаются
 
Реакции: kick и Psycho

    Psycho

    Баллов: 25
    За помощь!

    kick

    Баллов: 75
    756
И как же ему правильно в IDE это указать? В апликейшене?


Опа, щас вот так настроил, и всё заработало без проблем, берет файлы там где нужно, и на c3p0 заработал. Спасибо за помощь.
Код:
[main] INFO l2j.commons.util.CommonUtil - ------------------------------------------------------------------------------------------------------=[ Configuration ]
[main] INFO l2j.commons.config.ConfigManager - Loaded 3 config file(s).
[main] INFO l2j.commons.util.CommonUtil - ------------------------------------------------------------------------------------------------------=[ Shutdown Hook ]
[main] INFO l2j.commons.lang.management.ShutdownManager - Initialized.
[main] INFO l2j.commons.util.CommonUtil - --------------------------------------------------------------------------------------------------=[ Deadlock Detector ]
[main] INFO l2j.commons.lang.management.DeadlockDetector - Disabled.
[main] INFO l2j.commons.util.CommonUtil - -----------------------------------------------------------------------------------------------------=[ Thread Pool(s) ]
[main] INFO l2j.commons.util.concurrent.ThreadPool - Initialized with
[main] INFO l2j.commons.util.concurrent.ThreadPool -     ... 4/4 scheduled thread(s).
[main] INFO l2j.commons.util.concurrent.ThreadPool -     ... 4/4 thread(s).
[main] INFO l2j.commons.util.CommonUtil - -----------------------------------------------------------------------------------------------------------=[ Database ]
апр 17, 2019 1:48:30 PM com.mchange.v2.log.MLog <clinit>
INFO: MLog clients using java 1.4+ standard logging.
апр 17, 2019 1:48:30 PM com.mchange.v2.c3p0.C3P0Registry banner
INFO: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
апр 17, 2019 1:48:30 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 5, acquireRetryAttempts -> 0, acquireRetryDelay -> 500, autoCommitOnClose -> true, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge14za2bwn075cymnop|6cd8737, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> null, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge14za2bwn075cymnop|6cd8737, idleConnectionTestPeriod -> 3600, initialPoolSize -> 10, jdbcUrl -> jdbc:mysql://localhost/l2j?useSSL=false&serverTimezone=Europe/Moscow, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 10, maxStatements -> 0, maxStatementsPerConnection -> 100, minPoolSize -> 10, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
[main] INFO l2j.commons.sql.DatabaseFactory - Initialized DB 'jdbc:mysql://localhost/l2j?useSSL=false&serverTimezone=Europe/Moscow' as user 'root'.
[main] INFO l2j.commons.util.CommonUtil - --------------------------------------------------------------------------------------------------------=[ Application ]
[main] INFO l2j.commons.util.CommonUtil - ------------------------------------------------------------------------------------------------------------=[ Manager ]
[main] INFO l2j.loginserver.LoginController - Loading LoginController...
[main] INFO l2j.loginserver.LoginController - Cached 10 KeyPairs for RSA communication
[main] INFO l2j.loginserver.LoginController - Stored 20 keys for Blowfish communication
[main] INFO l2j.loginserver.GameServerTable - Loaded 1 registered Game Servers
[main] INFO l2j.loginserver.GameServerTable - Cached 10 RSA keys for Game Server communication.
[main] INFO l2j.loginserver.GameServerTable - Loaded 126 server names
[main] WARN l2j.loginserver.L2LoginServer - IP Bans file (banned_ip.cfg) is missing or is a directory, skipped.
[main] INFO l2j.loginserver.L2LoginServer - Listening for GameServers on 127.0.0.1:9014
[main] INFO l2j.loginserver.L2LoginServer - L2LoginServer: is now listening on: *:2106
[main] INFO l2j.commons.util.CommonUtil - ---------------------------------------------------------------------------------------------------------------=[ UPnP ]
[main] INFO l2j.commons.network.UPnPService - UPnP is disabled.
[main] INFO l2j.commons.util.CommonUtil - ----------------------------------------------------------------------------------------------=[ Execution Environment ]
[main] INFO l2j.commons.util.AppInit - Version Info - IDE Mode.
[main] INFO l2j.commons.util.AppInit - Version Info - IDE Mode.
[main] INFO l2j.commons.util.AppInit - Version Info - IDE Mode.
[main] INFO l2j.commons.util.CommonUtil - ------------------------------------------------------------------------------------------------------=[ Memory (Heap) ]
[main] INFO l2j.commons.util.AppInit - GC done in 48 milliseconds, 828 microseconds, 504 nanoseconds.
[main] INFO l2j.commons.util.AppInit - +----
[main] INFO l2j.commons.util.AppInit - | Global Memory Information at 13:48:32:
[main] INFO l2j.commons.util.AppInit - |    |
[main] INFO l2j.commons.util.AppInit - | Allowed Memory: 1,8 GB
[main] INFO l2j.commons.util.AppInit - |    |= Allocated Memory: 155,5 MB (8,60%)
[main] INFO l2j.commons.util.AppInit - |    |= Non-Allocated Memory: 1,6 GB (91,40%)
[main] INFO l2j.commons.util.AppInit - | Allocated Memory: 155,5 MB
[main] INFO l2j.commons.util.AppInit - |    |= Used Memory: 8,8 MB (0,49%)
[main] INFO l2j.commons.util.AppInit - |    |= Unused (cached) Memory: 146,7 MB (8,12%)
[main] INFO l2j.commons.util.AppInit - | Useable Memory: 1,8 GB (99,51%)
[main] INFO l2j.commons.util.AppInit - +----
[main] INFO l2j.commons.util.CommonUtil - ------------------------------------------------------------------------------------------------------------=[ Summary ]
[main] INFO l2j.commons.util.AppInit - Initialized in 3 seconds, 139 milliseconds.
[main] INFO l2j.commons.util.CommonUtil - -----------------------------------------------------------------------------------------------------=[ ApplicationLog ]
 
Вон у тебя use classpath of module [java].
Когда сделаешь 2 отдельных модуля и внутри них папки все добавишь нужные в classpath - выберешь нужный и поидее должно заработать
 
Изменил working directory и shorten command line, затарахтело.

Из полезного, разобрался как hikari прикручивать
Подрезав некоторые файлы в сурсах, уменьшил кол-во используемых библиотек, что тоже не плохо)

// Можно закрывать, всем спасибо.
 
Последнее редактирование модератором:
Выложи скрин конечной конфигурации апликецшна)
 
Последнее редактирование:
Ну значит не понадобилось даже дробить модули, поздравляю с результатом ))
 
Реакции: Psycho

    Psycho

    Баллов: 25
    Спасибо
Какие преимущества от него?
Думал из-за c3p0 не запускается логин. А так хер его знает кто и что там лучше.

Зато разобрался как избавиться от этого говна пока ковырял:
Код:
l2junity-plugin-yal2logger

Ну у меня они выглядят вот так:

В оригинале так:


Кстати, логин конектится к хф клиенту. Осталось подогнать гейм.