diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-02 14:17:45 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-02 14:17:45 +1300 |
commit | 892d1bad5c4dd1e07fe59c5c60e3b94617b0e725 (patch) | |
tree | e54cd30ad56e7c40bf4215440a4092a55044245e /src/org/traccar/database | |
parent | 329014781823c4fa43cffb61682cb670d55285e7 (diff) | |
download | trackermap-server-892d1bad5c4dd1e07fe59c5c60e3b94617b0e725.tar.gz trackermap-server-892d1bad5c4dd1e07fe59c5c60e3b94617b0e725.tar.bz2 trackermap-server-892d1bad5c4dd1e07fe59c5c60e3b94617b0e725.zip |
Handle new Java class loader (fix #4130)
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index c3a53f4b6..3d88b842d 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -103,10 +103,17 @@ public class DataManager { String driverFile = config.getString("database.driverFile"); if (driverFile != null) { - URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); - Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - method.setAccessible(true); - method.invoke(classLoader, new File(driverFile).toURI().toURL()); + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + try { + Method method = classLoader.getClass().getDeclaredMethod("addURL", URL.class); + method.setAccessible(true); + method.invoke(classLoader, new File(driverFile).toURI().toURL()); + } catch (NoSuchMethodException e) { + Method method = classLoader.getClass() + .getDeclaredMethod("appendToClassPathForInstrumentation", String.class); + method.setAccessible(true); + method.invoke(classLoader, driverFile); + } } String driver = config.getString("database.driver"); |