Having trouble getting Joda Time to work with my plugin

Discussion in 'Plugin Development' started by ProtoTempus, Jun 7, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    ProtoTempus

    I am attempting to use Joda-Time with my bukkit plugin, however I am running into ClassNotFoundException and a NoClassDefFoundError.
    I am using eclipse and have added it to my Build Path, and modified my Class-Path variable in my MANIFEST in the jar (and then adding the jar to a lib folder outside of my jar file), as well as tried to add the joda-time jar files in my jar file.

    I've tried converting my project to maven (via eclipse) and added joda-time as a dependency to the pom.xml, but I cant seem to get that to work either (Maybe I'm doing something wrong).


    If you need anymore information please ask. I'm not sure what else to include.
    Thanks for any help you can give me.

    Code:
    java.lang.NoClassDefFoundError: org/joda/time/ReadableInstant
            at com.**********.plugin.UMSBase.registerEvents(UMSBase.java:46)
            at com.***********.plugin.UMSBase.onEnable(UMSBase.java:22)
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
    .java:457)
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
    r.java:381)
            at org.bukkit.craftbukkit.v1_5_R2.CraftServer.loadPlugin(CraftServer.jav
    a:282)
            at org.bukkit.craftbukkit.v1_5_R2.CraftServer.enablePlugins(CraftServer.
    java:264)
            at net.minecraft.server.v1_5_R2.MinecraftServer.j(MinecraftServer.java:3
    03)
            at net.minecraft.server.v1_5_R2.MinecraftServer.e(MinecraftServer.java:2
    82)
            at net.minecraft.server.v1_5_R2.MinecraftServer.a(MinecraftServer.java:2
    42)
            at net.minecraft.server.v1_5_R2.DedicatedServer.init(DedicatedServer.jav
    a:150)
            at net.minecraft.server.v1_5_R2.MinecraftServer.run(MinecraftServer.java
    :381)
            at net.minecraft.server.v1_5_R2.ThreadServerApplication.run(SourceFile:5
    73)
    Caused by: java.lang.ClassNotFoundException: org.joda.time.ReadableInstant
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader
    .java:80)
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:53)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            ... 13 more
     
  2. Offline

    Tzeentchful

    ProtoTempus
    Have a look into using the maven shade plugin to combine the library with your plugin to make a uber jar.
     
  3. Offline

    ProtoTempus

    Thanks for the reply.

    I tried using maven, but couldn't figure it out. Do you perhaps have a link to a bukkit related tutorial?
     
  4. Offline

    ase34

    This gives an example for selecting contents for the uber jar: http://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html

    So you have to edit your pom like this:

    Code:
    <project>
      ...
      <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>
                  <artifactSet>
                    <excludes>
                      <exclude>org.bukkit:bukkit</exclude>
                    </excludes>
                    <includes>
                      <include>joda-time:joda-time</include>
                    </includes>
                  </artifactSet>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ... 
    </project>
    This is untested but should work (hopefully).
     
Thread Status:
Not open for further replies.

Share This Page