meta1203/Satoshis

NoClassDefFoundError onEnable

Closed this issue · 7 comments

I get this error when loading the plugin: java.lang.NoClassDefFoundError: com/google/bitcoin/core/ScriptException

I am building the lastest rev using ant and manually putting the dependencies in lib/.

How should I fix this?

2012-12-15 19:08:56 [INFO] [Satoshis] Enabling Satoshis v0.1
2012-12-15 19:08:56 [SEVERE] Error occurred while enabling Satoshis v0.1 (Is it up to date?)
java.lang.NoClassDefFoundError: com/google/bitcoin/core/ScriptException
        at me.meta1203.plugins.satoshis.Satoshis.onEnable(Unknown Source)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:374)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
        at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:270)
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:252)
        at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:579)
        at org.bukkit.Bukkit.reload(Bukkit.java:183)
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:502)
        at org.bukkit.craftbukkit.CraftServer.dispatchServerCommand(CraftServer.java:494)
        at net.minecraft.server.DedicatedServer.al(DedicatedServer.java:258)
        at net.minecraft.server.DedicatedServer.r(DedicatedServer.java:223)
        at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:493)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:426)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:856)
Caused by: java.lang.ClassNotFoundException: com.google.bitcoin.core.ScriptException
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:44)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
        ... 17 more

This is caused by not having the dependencies packaged into the jar. I use maven to do my packaging, which worked quite nicely, but Josh uses ant. However, the latest code uses BitcoinJ 0.6, which is not in BitcoinJ's maven repo. Let me poke around to see what I can do for maven; You will have to talk to Josh if you want to use ant.

In my development environment I launch the server this way:
java -Djava.ext.dirs="C:\Program Files\Java\jdk1.7.0_07\jre\lib\ext;lib" -jar craftbukkit-1.4.5-R0.2.jar

Where ./lib contains all the runtime libraries needed. I've uploaded my current runtime lib directory here for reference: http://forums.shapeandshare.com/runtime-libs.7z

Which leaves us at what we really should do...
In your opinion Josh, should the server owners start it with the dependencies in the classpath? Or should we just build the dependencies into the jar, and have the plugin access them from there? (I already have maven set up to do the latter, I just don't know how to do the same thing in ant.)

Unless we run into a licensing issue including the dependencies we should do this. It will make adoption and usage much easier. I just committed an update to do just this. Let me know if there are any issues. No need to update your runtime command, just launch server normally and place the jar into plugin directory.
Cheers!

Ok, I just saw something that seems to be a bit annoying with the ant build:
The final file size of Satoshis.jar is 15.4 MiB. That is more than CraftBukkit itself! Using maven, the final file size is 7.7 MiB, which seems to be much better! I'll compare your dependencies with mine, and see if I can eliminate some excess.

Great! I was able to build it using ant and run it on my server (after converting plugin.yml to unix line endings). With the latest commit it is 7.8MB. (I'm not sure how to build with maven). It downloaded the block chain in 3 minutes.

The plugin produces a lot of output on the server console, announcing each transaction. Maybe it could use a separate log file?

Off Topic Just for the record, once maven is installed on the build box, simply type "mvn package" to build the .jar. All dependencies are downloaded automatically, the code is build, and only the required dependencies are packaged in. The .jar will be located at "target/Satoshis-*.jar".

As for the log file, I just pushed some code that will limit the output of BitcoinJ to warnings or higher. Satoshis's logging should stay the same, however.