Solved "ClassNotFoundException" causing problems...

Discussion in 'Spigot Plugin Development' started by SrLegsini, Jun 3, 2017.

  1. Hi there. I have this error since I want to use SQLite (because I want to make a plugin compatible with mysql and sqlite, both of them). It doesn't detects the class "org.sqlite.JDBC", and I tried many ways: Importing as external jar at buildpath, importing as internal jar at buildpath, editing "classpath" file, etc... Nothing works. I'm actually using Eclipse Neon.3.

    P.S.: It happened again some months ago with Hikari libs.

    What can I do?
    Thank you.
     
  2. So when you run the server, the plugin gives you a ClassNotFoundException. Did you shade SQLite into your jar? When you open your jar with WinRar, does it contain both your plugin and SQLite?
     
  3. Yes, it does, it includes both of them, plugin and jar (and all classes). Everything seems to be good, but the error is there.
     
  4. md_5

    Administrator Developer

    Post the code you are using to detect it?
    A simple Class.forName should work, its bundled into CraftBukkit.
    Whats the full stack trace?
     
  5. The whole class: https://hastebin.com/ohitevirot.swift
    (Error at line 33, in the "Class.forName("org.sqlite.JDBC")).

    SQLite (sqlite-jdbc-3.18.0.jar) is imported and in buildpath, everything seems to be right.
    EDIT: Using BungeeCord (Build 1236). I guess it doesn't affects.
     
  6. md_5

    Administrator Developer

    It does, BungeeCord does not bundle sqlite. You need to include it with your plugin.
     
  7. I includes it... It's imported inside the plugin.

    EDIT: I mean... I imported the ".jar" inside the plugin and it's in the buildpath. Is this the correct way?
     
    #7 SrLegsini, Jun 4, 2017
    Last edited: Jun 4, 2017
  8. Open your plugin with a tool like WinRAR & try to find the class.
     
  9. md_5

    Administrator Developer

    You need the individual classes inside the plugin, not the jar. If using maven, then the shade plugin will do this. If using eclipse you'll need "jar with depends" or similar.
     
    • Informative Informative x 1
  10. It exists, I checked it.
     
  11. Well... Will see if I find the open source.
     
  12. Well, problem solved. I just opened SQLite .jar with Luyten and copied the classes to my project. Thank you, md_5.
     
    • Useful Useful x 1
  13. md_5

    Administrator Developer

    You don't need the actual source, just the class files is enough. Eclipse should do this automatically if you make a "jar with depends"