You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm a server side Java app (run with maven jetty) and I need to load, when required, a plugin.jar that is outside the classpath.
I do this with this code:
JarClassLoader jcl = new JarClassLoader();
jcl.add(pluginFile.getPath());
JclObjectFactory factory = JclObjectFactory.getInstance();
// Create object of loaded class
JarFile jarFile = new JarFile(pluginFile);
Enumeration<JarEntry> e = jarFile.entries();
while (e.hasMoreElements()) {
JarEntry je = (JarEntry) e.nextElement();
if (je.isDirectory() || !je.getName().endsWith(".class")) {
continue;
}
// -6 because of .class
String className = je.getName().substring(0, je.getName().length() - 6);
className = className.replace('/', '.');
Object obj = factory.create(jcl, className);
log.debug("Classe restituita: "+obj);
return obj;
}
then I invoke a method from this plugin class, say doSomething().
My plugin class in short make an access to a datasource (Dmbs) and inside is is included the jar needed to access the db.
in my doSomething() method I do this:
JarClassLoader jcl = new JarClassLoader();
jcl.add(".");
JclObjectFactory factory = JclObjectFactory.getInstance();
// Create object of loaded class
Object obj = factory.create(jcl, "com.mysql.jdbc.Driver");
Class.forName(dataSet.getDriver(), true, jcl);
Unfortunally when my server app try ti invoke doSomething() method I've always this exception:
26/07/2014 10:17:01 ERROR PluginManager:70 -
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/db
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
Jcl is supposed to solve this situation?
Thanks
The text was updated successfully, but these errors were encountered:
Hi,
I'm a server side Java app (run with maven jetty) and I need to load, when required, a plugin.jar that is outside the classpath.
I do this with this code:
JarClassLoader jcl = new JarClassLoader();
jcl.add(pluginFile.getPath());
JclObjectFactory factory = JclObjectFactory.getInstance();
then I invoke a method from this plugin class, say doSomething().
My plugin class in short make an access to a datasource (Dmbs) and inside is is included the jar needed to access the db.
in my doSomething() method I do this:
JarClassLoader jcl = new JarClassLoader();
jcl.add(".");
JclObjectFactory factory = JclObjectFactory.getInstance();
// Create object of loaded class
Object obj = factory.create(jcl, "com.mysql.jdbc.Driver");
Class.forName(dataSet.getDriver(), true, jcl);
Unfortunally when my server app try ti invoke doSomething() method I've always this exception:
26/07/2014 10:17:01 ERROR PluginManager:70 -
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/db
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
Jcl is supposed to solve this situation?
Thanks
The text was updated successfully, but these errors were encountered: