Помогите Проблема с Maven Redis Bukkit build

_MasterCapeXD_

Активный участник
Пользователь
Баллы
76
Имя в Minecraft
_MasterCapeXD_
Добавил в Maven проект зависимость Redis. При обычной сборке на сервере выскакивает ошибка NoClassDefFoundError на Jedis.class, а когда добавляю плагин, то получается Build Failure
Помогите, пожалуйста

pom.xml:
Код:
<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>me.mastercapexd.staff</groupId>
  <artifactId>Staff</artifactId>
  <version>0.0.1-SNAPSHOT</version>
 
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <relocations>
                                <relocation>
                                    <pattern>redis.clients.jedis</pattern>
                                    <shadedPattern>your.package.here.shaded.redis.clients.jedis</shadedPattern>
                                    <pattern>org.apache.commons</pattern>
                                    <shadedPattern>your.package.here.shaded.org.apache.commons</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
  </build>
 
  <repositories>
    <repository>
        <id>spigot-repo</id>
        <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
    </repository>
    <repository>
        <id>vault-repo</id>
        <url>http://nexus.hc.to/content/repositories/pub_releases</url>
    </repository>
  </repositories>
 
  <dependencies>
    <!--Spigot API-->
    <dependency>
           <groupId>org.spigotmc</groupId>
           <artifactId>spigot-api</artifactId>
           <version>1.8-R0.1-SNAPSHOT</version>
           <scope>provided</scope>
    </dependency>
    <!--Bukkit API-->
    <dependency>
            <groupId>org.bukkit</groupId>
            <artifactId>bukkit</artifactId>
            <version>1.8-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
    </dependency>
    <!--Vault API-->
    <dependency>
        <groupId>net.milkbowl.vault</groupId>
        <artifactId>VaultAPI</artifactId>
        <version>1.7</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
        <version>2.4.2</version>
    </dependency>
  </dependencies>
</project>

Код:
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Staff 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Staff ---
[WARNING] Using platform encoding (Cp1251 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Staff ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Staff ---
[WARNING] Using platform encoding (Cp1251 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ Staff ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ Staff ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ Staff ---
[INFO] Building jar: D:\Other\Data\development\Java\my projects\Spigot\Staff\target\Staff-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-shade-plugin:2.1:shade (default) @ Staff ---
[INFO] Including redis.clients:jedis:jar:2.4.2 in the shaded jar.
[INFO] Including org.apache.commons:commons-pool2:jar:2.0 in the shaded jar.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.357 s
[INFO] Finished at: 2018-11-07T19:20:08+02:00
[INFO] Final Memory: 12M/212M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.1:shade (default) on project Staff: Error creating shaded jar: 13932 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
 
<pattern>redis.clients.jedis</pattern>
<shadedPattern>your.package.here.shaded.redis.clients.jedis</shadedPattern>

Жесть релокация
 
В одной relocation может быть только одна pattern и одна shadedPattern.
Хотя ... ошибка про это явно не указывает. Может и так пережовывает.
 
Изменил <build></build>:

Код:
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <relocations>
                                <relocation>
                                    <pattern>redis.clients.jedis</pattern>
                                    <shadedPattern>your.package.here.shaded.redis.clients.jedis</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.commons</pattern>
                                    <shadedPattern>your.package.here.shaded.org.apache.commons</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
  </build>

В Bukkit плагине ничего не изменилось, билд не хочет успешно завершаться.
В BungeeCord всё компилится, разницы в <build></build> никакой.
Зависимости:
Код:
  <repositories>
    <repository>
        <id>spigot-repo</id>
        <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
    </repository>
    <repository>
        <id>vault-repo</id>
        <url>http://nexus.hc.to/content/repositories/pub_releases</url>
    </repository>
  </repositories>
 
  <dependencies>
    <!--Spigot API-->
    <dependency>
           <groupId>org.spigotmc</groupId>
           <artifactId>spigot-api</artifactId>
           <version>1.8-R0.1-SNAPSHOT</version>
           <scope>provided</scope>
    </dependency>
    <!--Bukkit API-->
    <dependency>
            <groupId>org.bukkit</groupId>
            <artifactId>bukkit</artifactId>
            <version>1.8-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
    </dependency>
    <!--Vault API-->
    <dependency>
        <groupId>net.milkbowl.vault</groupId>
        <artifactId>VaultAPI</artifactId>
        <version>1.7</version>
        <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
        <version>2.9.0</version>
    </dependency>
  </dependencies>
Код:
  <repositories>
    <repository>
        <id>BungeeCord-repo</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
  </repositories>
 
  <dependencies>
    <!--BungeeCord API-->
    <dependency>
        <groupId>net.md-5</groupId>
        <artifactId>bungeecord-api</artifactId>
        <version>1.7-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
        <version>2.9.0</version>
    </dependency>
  </dependencies>
 
Изменил <build></build>:

Код:
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <relocations>
                                <relocation>
                                    <pattern>redis.clients.jedis</pattern>
                                    <shadedPattern>your.package.here.shaded.redis.clients.jedis</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.commons</pattern>
                                    <shadedPattern>your.package.here.shaded.org.apache.commons</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
  </build>

В Bukkit плагине ничего не изменилось, билд не хочет успешно завершаться.
В BungeeCord всё компилится, разницы в <build></build> никакой.
Зависимости:
Код:
  <repositories>
    <repository>
        <id>spigot-repo</id>
        <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
    </repository>
    <repository>
        <id>vault-repo</id>
        <url>http://nexus.hc.to/content/repositories/pub_releases</url>
    </repository>
  </repositories>
 
  <dependencies>
    <!--Spigot API-->
    <dependency>
           <groupId>org.spigotmc</groupId>
           <artifactId>spigot-api</artifactId>
           <version>1.8-R0.1-SNAPSHOT</version>
           <scope>provided</scope>
    </dependency>
    <!--Bukkit API-->
    <dependency>
            <groupId>org.bukkit</groupId>
            <artifactId>bukkit</artifactId>
            <version>1.8-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
    </dependency>
    <!--Vault API-->
    <dependency>
        <groupId>net.milkbowl.vault</groupId>
        <artifactId>VaultAPI</artifactId>
        <version>1.7</version>
        <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
        <version>2.9.0</version>
    </dependency>
  </dependencies>
Код:
  <repositories>
    <repository>
        <id>BungeeCord-repo</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
  </repositories>
 
  <dependencies>
    <!--BungeeCord API-->
    <dependency>
        <groupId>net.md-5</groupId>
        <artifactId>bungeecord-api</artifactId>
        <version>1.7-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
        <version>2.9.0</version>
    </dependency>
  </dependencies>
А довай ты ошибку сборки скинешь не?
 
А довай ты ошибку сборки скинешь не?
Ошибка та же самая.
Но я решил это, используя другие настройки плагинов:

Код:
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8.0_161</source>
                    <target>1.8.0_161</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>App.CytoVisProject</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
  </build>
 
Только теперь для меня проблема создать нормальное подключение к Jedis серверу, ну и его создание.
Перерыл кучу сайтов, пробовал разные способы, но в моём случаи - только ошибки подключения.

  • В общем, мне нужно записывать ключ=значение в BungeeCord плагине. Тоесть, сервер нужно создать на уровне BungeeCord, и добавлять некоторые записи при ивентах BungeeCord.

  • Со стороны Bukkit нужно подключиться к существующему Jedis серверу и просто получать значение по известному ключу в определенных методах.

Очень буду признателен, если скинете схематический участок кода для каждого из пунктов. Думаю, что в общей сложности это не более 20 строк, но Вы очень сильно мне поможете.
 
Код:
        this.jedis = new Jedis(getConfig().getString("host"),getConfig().getInt("port"));
        jedis.auth(getConfig().getString("pass"));
 
Ошибка((
Код:
21:45:23 [WARNING] Exception encountered when loading plugin: StaffBungee
redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect
    at redis.clients.jedis.Connection.connect(Connection.java:207)
    at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93)
    at redis.clients.jedis.Connection.sendCommand(Connection.java:126)
    at redis.clients.jedis.Connection.sendCommand(Connection.java:117)
    at redis.clients.jedis.BinaryClient.auth(BinaryClient.java:564)
    at redis.clients.jedis.BinaryJedis.auth(BinaryJedis.java:2138)
    at me.mastercapexd.staff.bungee.messaging.BungeeServer.<init>(BungeeServer.java:19)
    at me.mastercapexd.staff.bungee.StaffPlugin.onEnable(StaffPlugin.java:22)
    at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:227)
    at net.md_5.bungee.BungeeCord.start(BungeeCord.java:303)
    at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:37)
    at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at redis.clients.jedis.Connection.connect(Connection.java:184)
    ... 11 more

Сам код:

Код:
    private final PluginConf pluginConf;
    private final Jedis jedis;
    
    public BungeeServer(PluginConf pluginConf) {
        this.pluginConf = pluginConf;
        this.jedis = new Jedis(pluginConf.getHost(), pluginConf.getPort());
        jedis.auth(pluginConf.getPassword());
    }
// ...
}
 
Назад
Верх