I maintain a karaf feature that loads the liquibase[1] database
migration system.
With version 4.23.0 of liquibase my liquibase karaf feature[2] loaded
fine in both karaf and the feature's pax exam test.
But from version 4.23.1 of liquibase the feature still loads fine in
karaf, but fails in the pax exam test based on the same version of karaf
4.4.4.
And I struggle to see what the difference is, and would appreciate some
fresh eyes on it.
A point that may be significant: liquibase uses the Java Service
Provider Interface[3] to load services.
And my liquibase karaf feature uses Apache Aries SPI Fly[4] to make the
services load in OSGi in karaf.
I also build with JDK 17 and run karaf with Java 17.
The karaf feature integration test consists of
1. The karaf.liquibase.sample[5] bundle, containing:
1. a feature repository[6] that depends on scr and derby, defines a
pax-jdbc config feature "sample-db" and a feature that loads the
preHook
2. A DS component implementing the preHook used by sample-db[7]
2. The karaf.liquibase.services bundle defining a single interface
SampleLiquibaseDatasourceReceiverService[8]
3. The karaf.liquibase.sample.datasource.receiver bundle[9] which
creates a DS component implementing the service in[8] and a karaf
feature depending in the feature from the karaf.liquibase.sample[5] bundle
and the
feature from the karaf.liquibase.services[8] bundle
4. The pax exam test[10] that loads the feature of the
karaf.liquibase.sample.datasource.receiver[9] bundle and then uses
the created database (saves some data and verifies that the data can
be loaded back using jdbc)
The pax exam test fails in loading the
karaf-liquibase-sample-datasource-receiver
feature from the feature repository
mvn:no.priv.bang.karaf/karaf.liquibase.sample.datasource.receiver/LATEST/xml/features
The feature load fails here in karaf.log:
https://gist.github.com/steinarb/7e6429d78ac30aa24b8228feb4ac814e#file-karaf-log-L333
At the same point in a regular karaf 4.4.4, the feature load succeeds
and starts creating the database schema:
https://gist.github.com/steinarb/5e6b57c7426fb5e2d5d07c35e3edb45e#file-karaf-log-L263
Not much to go on here, but I think that since this works with liquibase
4.23.0 my best guess is that there is some dependency or something I'm
missing in the pax exam test...?
Other more exotic hypotheses is that there is some mystic pax exam
process reload that causes the in-memory database to go suddenly away at
this point (but if so: why does it work for liquibase 4.23.0?).
To reproduce, first clone and build the current version:
git clone https://github.com/steinarb/liquibase-karaf-feature.git
cd liquibase-karaf-feature
mvn clean install
Then change the liquibase version at line 29 of the pom[11] and build
with
mvn clean install
Then this fails in the integration test.
The feature that fails in the integration test loads fine in regular
karaf 4.4.4, with[12]:
feature:repo-add
mvn:no.priv.bang.karaf/karaf.liquibase.sample.datasource.receiver/LATEST/xml/features
feature:install karaf-liquibase-sample-datasource-receiver
References
[1] <https://www.liquibase.org>
[2] <https://github.com/steinarb/liquibase-karaf-feature>
[3] <https://www.baeldung.com/java-spi>
[4] <https://aries.apache.org/documentation/modules/spi-fly.html>
[5]
<https://github.com/steinarb/liquibase-karaf-feature/tree/master/liquibase-integration-test/karaf.liquibase.sample>
[6]
<https://github.com/steinarb/liquibase-karaf-feature/blob/master/liquibase-integration-test/karaf.liquibase.sample/src/main/feature/feature.xml#L15>
[7]
<https://github.com/steinarb/liquibase-karaf-feature/blob/master/liquibase-integration-test/karaf.liquibase.sample/src/main/java/no/priv/bang/karaf/sample/db/liquibase/test/SampleDbLiquibaseRunner.java#L44>
[8]
<https://github.com/steinarb/liquibase-karaf-feature/blob/master/liquibase-integration-test/karaf.liquibase.sample.services/src/main/java/no/priv/bang/karaf/liquibase/sample/services/SampleLiquibaseDatasourceReceiverService.java#L21C18-L21C58>
[9]
<https://github.com/steinarb/liquibase-karaf-feature/tree/master/liquibase-integration-test/karaf.liquibase.sample.datasource.receiver>
[10]
<https://github.com/steinarb/liquibase-karaf-feature/blob/master/liquibase-integration-test/karaf.liquibase.tests/src/test/java/no/priv/bang/karaf/liquibase/tests/LiquibaseKarafFeatureIntegrationTest.java#L37>
[11]
<https://github.com/steinarb/liquibase-karaf-feature/blob/master/pom.xml#L29>
[12]
<https://github.com/steinarb/liquibase-karaf-feature#testing-and-debugging-in-karaf>