0

I'm writing a plugin for Spigot/Bukkit (Minecraft) in Java and can't figure out how to fix this problem for the life of me. Although I have done a lot of programming in other languages, this is my first attempt at programming in java. I have done many google searches, looked at dozens of pages, but everything just said to do things I have already tried.

I'm using eclipse and have converted my project to and from a maven project trying all sorts of variations of installing the mongo java driver. I've tried:
- Adding dependency/s
- Adding it to the buildpath using project->properties->Java Build Path->Add External Jar
- I've done a combination of both of the above
- I've tried using mongodb-driver, mongodb-driver-core and bson together, and with mongodb-java-driver(which should just work on it's own.)
- I've tried just using mongodb-java-driver
- I've tried using many different versions of the drivers.

It doesn't matter what I do, when I export my plugin to a jar and attempt to run it on my spigot server I get the following error:

java.lang.NoClassDefFoundError: com/mongodb/MongoClientURI

Where MongoClientURI could be replaced by any mongo class I use in my code. Am I not using the driver correctly, am I missing something? What's going on?

1 Answer 1

1

So I solved my own problem in the end. Turns out spigot doesn't recognize any jar files other than spigot plugins on execution. Shading would've solved my issue but instead I did this, which also works:

  1. Created a file called MANIFEST.MF within my project directory.
  2. Added the following to the file:

    Manifest-Version: 1.0
    Class-Path: libs/mongo-java-driver-3.2.2.jar
    Created-By: 1.7.0_06 (Oracle Corporation)

  3. Selected "Use existing manifest from workspace" in the final step of exporting my plugin.

This meant that at runtime spigot would include {plugin location}/libs/mongo-java-driver-3.2.2.jar in it's libraries.

I found my solution here: https://www.spigotmc.org/threads/solved-mongodb-help.35922/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.