Maven pom and Jedis (Redis)

Discussion in 'Spigot Plugin Development' started by joeygallegos, Jun 27, 2015.

  1. I'm trying to use Jedis in my plugin, and in my onEnable I initialize with this code:
    PHP:
    pool = new JedisPool(new JedisPoolConfig(), HOST, PORT, 0);

    Jedis jedis = getPool().getResource();
    jedis.ping();

    getPool().returnResource(jedis);
    I see nothing wrong with this, but when server starts, I get a weird exception that doesn't seem to be related to me whatsoever:

    Code (Text):
    [14:44:45] [Server thread/ERROR]: Error occurred while enabling ClarityCore v1.0 (Is it up to date?)
    java.lang.IllegalArgumentException: Unable to create EvictionPolicy instance of type org.apache.commons.pool2.impl.DefaultEvictionPolicy
        at org.apache.commons.pool2.impl.BaseGenericObjectPool.setEvictionPolicyClassName(BaseGenericObjectPool.java:607) ~[?:?]
        at org.apache.commons.pool2.impl.GenericObjectPool.setConfig(GenericObjectPool.java:321) ~[?:?]
        at org.apache.commons.pool2.impl.GenericObjectPool.<init>(GenericObjectPool.java:117) ~[?:?]
        at redis.clients.util.Pool.initPool(Pool.java:43) ~[?:?]
        at redis.clients.util.Pool.<init>(Pool.java:31) ~[?:?]
        at redis.clients.jedis.JedisPool.<init>(JedisPool.java:73) ~[?:?]
        at redis.clients.jedis.JedisPool.<init>(JedisPool.java:63) ~[?:?]
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool2.impl.DefaultEvictionPolicy
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_40]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_40]
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[?:1.8.0_40]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_40]
        at java.lang.Class.forName0(Native Method) ~[?:1.8.0_40]
        at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_40]
        at org.apache.commons.pool2.impl.BaseGenericObjectPool.setEvictionPolicyClassName(BaseGenericObjectPool.java:598) ~[?:?]
        ... 19 more
     
    My pom looks like this:
    Code (Text):
    <?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>com.claritygalaxy</groupId>
        <artifactId>ClarityCore</artifactId>
        <version>0.5-SNAPSHOT</version>
        <packaging>jar</packaging>

        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        </properties>

        <build>
            <plugins>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>

                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>com.claritygalaxy.serverapi.ClarityCore</mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>2.2</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <createDependencyReducedPom>false</createDependencyReducedPom>
                        <minimizeJar>true</minimizeJar>
                        <filters>
                            <filter>
                                <artifact>com.google.gson:gson</artifact>
                                <includes>
                                    <include>**</include>
                                </includes>
                            </filter>
                            <filter>
                                <artifact>redis.clients.jedis:Jedis</artifact>
                                <includes>
                                    <include>**</include>
                                </includes>
                            </filter>
                            <filter>
                                <artifact>org.apache.commons.pool:commons-pool2</artifact>
                                <includes>
                                    <include>**</include>
                                </includes>
                            </filter>
                        </filters>
                    </configuration>
                </plugin>
            </plugins>
        </build>

        <repositories>
            <repository>
                <id>sacredlibyrinth</id>
                <url>http://sacredlabyrinth.net/artifactory/repo/</url>
            </repository>
        </repositories>

        <dependencies>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-pool2</artifactId>
                <version>2.3</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>redis.clients</groupId>
                <artifactId>jedis</artifactId>
                <version>2.4.2</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>2.3.1</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.twitter</groupId>
                <artifactId>hbc-twitter4j</artifactId>
                <version>2.2.0</version>
            </dependency>
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot-api</artifactId>
                <version>1.8-R0.1-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.bukkit</groupId>
                <artifactId>bukkit</artifactId>
                <version>1.8-R0.1-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot</artifactId>
                <version>1.8-R0.1-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.14.4</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </project>
    Any suggestions?
    EDIT: Me and a friend have a sneaking suspicion this is what's causing the problem:
    Code (Text):
    <filter>
        <artifact>org.apache.commons.pool:commons-pool2</artifact>
        <includes>
            <include>**</include>
        </includes>
    </filter>
     
    #1 joeygallegos, Jun 27, 2015
    Last edited: Jun 27, 2015