ClassNotFoundException MongoDB

Discussion in 'Plugin Development' started by MrTwiggy, Feb 6, 2013.

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


    Hey there, I really need some help on this. I'm extremely stuck.

    I'm attempting to use the MongoDB java driver (not bukkit or minecraft related) to gain access to my database. Everything works fine when I create a new (regular) java project, add the mongo java driver to my build path, and then compile it with small tests. But, when I add the mongo java driver .jar file to my Bukkit project, I have the ability to import the required files from the java driver (EX: com.mongodb.MongoClient), and there are no errors. But when I compile and then start up my server, I get errors like NoClassDefFound and NoClassFoundException: com.mongodb.MongoClient.

    TL;DR I have a non-bukkit/minecraft related library that I added to my build path correctly, but can't be found when I compile and run my server.


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 31, 2016
  2. Offline


    You have to load it with a class loader or add it to the class-path field of your MANIFEST.MF.
  3. Offline


    Alright, thank you. However, I'm not familiar with using class loaders or even where I can find the 'MANIFEST.MF', or even the format of the manifest. Where can I find/create the manifest, and what is the format for adding the java driver to my build path for it?
  4. Offline


    If you're using eclipse, when exporting, click next until the last page and choose one of the manifest options.
  5. Offline


    I created a file 'MANIFEST.MF' in my .jar in eclipse, and I put this in it
    Manifest-Version: 1.0
    Created-By: 1.7.0_06 (Oracle Corporation)
    Class-Path: mongo.jar
    I pointed towards that during the exporting of my plugin .jar file, however, I am still receiving the errors, even though I put the mongo.jar in the plugins folder along with my plugin jar.

    EDIT: Nvm, removing the 'Created-By' fixed everything. Thanks.
  6. Offline


    You have to put mongo.jar in your server folder.
  7. Offline

    Sagacious_Zed Bukkit Docs

    The Class-Path entry is relative to the jar it is in. Or it should be.
Thread Status:
Not open for further replies.

Share This Page