karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steinar Bang ...@dod.no>
Subject Re: "No suitable driver found" after postgresql driver bundle reload
Date Sun, 28 Apr 2019 19:03:50 GMT
>>>>> Jean-Baptiste Onofré <jb@nanthrax.net>:

> The "classic" workaround for Class.forName() is to use a TCCL
> (ThreadContextClassLoader).

Thanks for the tip.

Turns out it was a Class.forName() issue, but not in the PostgreSQL JDBC
driver, but in rt.jar where it could not easily be fixed:
 https://github.com/pgjdbc/pgjdbc/issues/1476

The comparison between the class of the driver and result of
Class.forName() of the driver's name returns false:
    private static boolean isDriverAllowed(Driver driver, ClassLoader classLoader) {
        boolean result = false;
        if(driver != null) {
            Class<?> aClass = null;
            try {
                aClass =  Class.forName(driver.getClass().getName(), true, classLoader);
            } catch (Exception ex) {
                result = false;
            }

             result = ( aClass == driver.getClass() ) ? true : false;
        }

        return result;
    }

Before the bundle reload, this comparison works (I've remote debugged
through the getConnection() method for both cases).


Mime
View raw message