Custom Plugin getting ClassNotFoundException:org.sqlite.JDBC

Hi everyone,

I developed a custom servoy plugin that for now only has 2 methods, one that opens a connection to a sqlite database and another that closes that connection. The plugin’s jar includes the sqlite jar and I have some test cases in junit where I could test the methods and they seem to work perfectly.

My problem is when I use the plugin in servoy like this:

plugins.SQLiteConverter.openConnection(plugins.file.getHomeFolder() + '/local.db');
plugins.SQLiteConverter.closeConnection();

I always get this message:

Wrapped java.lang.ClassNotFoundException: org.sqlite.JDBC (C:\servoy\workspaces\servoy6_ddFramework\dd_mScannerBatchProcess\globals.js#15)
at C:\servoy\workspaces\servoy6_ddFramework\dd_mScannerBatchProcess\globals.js:15 (testPlugin)
at C:\servoy\workspaces\servoy6_ddFramework\dd_mScannerService\forms\dd_scnsrv_dd_scnsrv_datasource_frm.js:133 (onActionCreateDB)

The existing code in my IScriptObject implementation is this:

public void js_openConnection(String dbPath) throws ClassNotFoundException {

		ClassLoader cl = this.getClass().getClassLoader();
		Class.forName("org.sqlite.JDBC", true, cl);

		try {
			// create a database connection
			dbConnection = DriverManager.getConnection("jdbc:sqlite:" + dbPath);

		} catch (SQLException e) {
			System.err.println(e.getMessage());
		}
	}

Maybe it is a simple classpath problem, but I don’t know where to fix it…
I also have the same sqlite jdbc jar in the drivers folder of the application server, so I’m kind of out of ideas…

Anyone has any clue?

Thanks!

Ok, so I’ll answer my own question :D

Apparently is quite simple, I just had to and a jnlp file next to the generated jar, and in this file I added the reference to the sqlite jdbc jar that I wanted to include.

<?xml version="1.0" encoding="utf-8"?>


SQLite Converter xxx