Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-8480

PostgreSQL driver's OSGi bundle activator deregisters the driver

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 18.0.1
    • Fix Version/s: 18.0.1
    • Component/s: Database
    • Security Level: Default (Default Security Scheme)
    • Labels:
      None

      Description

      After merging the updated PostgreSQL driver into our 18.0.1 branch, test failures cropped up in projects using the PojoSR test framework. It turns out that the new driver has an OSGi bundle activator that will register and deregister the driver as the bundle loads and unloads.

      This causes problems when a project has a mix of OSGi and regular tests since the driver can be deregistered by PojoSR right before a regular test runs.

      Sample exception:

      2016-05-31 17:30:42,843 WARN [main] org.springframework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.opennms.core.test.db.TemporaryDatabaseExecutionListener@18
      99c7ae] to process 'before class' callback for test class [class org.opennms.netmgt.syslogd.SyslogdIT]
      java.util.concurrent.ExecutionException: org.opennms.core.test.db.TemporaryDatabaseException: Failed to get admin connection.
              at java.util.concurrent.FutureTask.report(FutureTask.java:122)
              at java.util.concurrent.FutureTask.get(FutureTask.java:192)
              at org.opennms.core.test.db.TemporaryDatabaseExecutionListener.beforeTestClass(TemporaryDatabaseExecutionListener.java:230)
              at org.springframework.test.context.TestContextManager.beforeTestClass(TestContextManager.java:298)
              at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:60)
              at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
              at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
              at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:176)
              at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
              at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
              at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
              at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
              at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
              at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
      Caused by: org.opennms.core.test.db.TemporaryDatabaseException: Failed to get admin connection.
              at org.opennms.core.test.db.TemporaryDatabasePostgreSQL.createTestDatabase(TemporaryDatabasePostgreSQL.java:315)
              at org.opennms.core.test.db.TemporaryDatabasePostgreSQL.setupDatabase(TemporaryDatabasePostgreSQL.java:297)
              at org.opennms.core.test.db.TemporaryDatabasePostgreSQL.create(TemporaryDatabasePostgreSQL.java:133)
              at org.opennms.core.test.db.TemporaryDatabaseExecutionListener.createNewDatabase(TemporaryDatabaseExecutionListener.java:293)
              at org.opennms.core.test.db.TemporaryDatabaseExecutionListener.access$000(TemporaryDatabaseExecutionListener.java:69)
              at org.opennms.core.test.db.TemporaryDatabaseExecutionListener$CreateNewDatabaseCallable.call(TemporaryDatabaseExecutionListener.java:278)
              at org.opennms.core.test.db.TemporaryDatabaseExecutionListener$CreateNewDatabaseCallable.call(TemporaryDatabaseExecutionListener.java:269)
              at java.util.concurrent.FutureTask.run(FutureTask.java:266)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
              at java.lang.Thread.run(Thread.java:745)
      Caused by: java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/template1
              at java.sql.DriverManager.getConnection(DriverManager.java:689)
              at java.sql.DriverManager.getConnection(DriverManager.java:208)
              at org.opennms.core.db.install.SimpleDataSource.getConnection(SimpleDataSource.java:93)
              at org.opennms.core.test.db.TemporaryDatabasePostgreSQL.createTestDatabase(TemporaryDatabasePostgreSQL.java:313)
              ... 10 more
      

        Attachments

          Activity

            People

            • Assignee:
              seth Seth Leger
              Reporter:
              seth Seth Leger
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: