karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steinar Bang ...@dod.no>
Subject "No suitable driver found" after postgresql driver bundle reload
Date Fri, 26 Apr 2019 21:19:53 GMT
I have the following problem:
 1. I use a karaf feature to load a DS component that takes a
    DatasourceFactory OSGi service reference[1]
 2. The karaf feature also loads the PostgreSQL driver bundle:
        <bundle start-level="80">mvn:org.postgresql/postgresql/42.2.5</bundle>
 3. The OSGi service created by [1] is injected into a DS component
    implementing an Apache Shiro JdbcRealm[2]
 4. The web service installed by the karaf feature works fine
 5. I then load a different karaf feature to load another DS component
    that takes a DatasourceFactory OSGi service reference[3]
 6. Now both web services fail, and the reason is this stack trace[4]
 7. I saw from the karaf.log that the postgresql bundle is stopped and
    started when installing feature number 2
 8. On the restart the activate() methods of both the DS component for
    the OSGi service[1] and [2] are called again, and they both have a
    new DataSource reference, and the new reference is the same for [1]
    and [2]

I think this is a PostgreSQL driver bug, because googling the stack
trace led me to a PostgreSQL driver bug from 2017, that have been fixed
since then[5].

However: I think I see some kind of OSGi version of the bug (the cure
mentioned, using Class.forName(), probably won't work in a OSGi

Has anyone else seen something similar?  Does anyone know of a fix or a
workaround for the issue?

(I can think of one possible workaround: create a karaf feature that
loads the PostgreSQL driver and its dependencies, and load this directly
before loading any other features.  Then maybe PostgreSQL won't reload
and this problem won't occur)


- Steinar

 [1] <https://github.com/steinarb/authservice/blob/master/authservice.db.postgresql/src/main/java/no/priv/bang/authservice/db/postgresql/PostgresqlDatabase.java#L37>
 [2] <https://github.com/steinarb/authservice/blob/master/authservice.web.security.dbrealm/src/main/java/no/priv/bang/authservice/web/security/dbrealm/AuthserviceDbRealm.java#L25>
 [3] <https://github.com/steinarb/ukelonn/blob/master/ukelonn.db.postgresql/src/main/java/no/priv/bang/ukelonn/db/postgresql/PGUkelonnDatabaseProvider.java#L42>
 [4] <https://gist.github.com/steinarb/d33ff99c19d929da4543bdd46d019ecf>
 [5] <https://github.com/pgjdbc/pgjdbc/issues/798>

View raw message