New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide Liquibase SLF4J bridge as an OSGi fragment #12
Comments
Hi. Thanks for reporting. I'm only vaguely familiar with OSGi and what I have been exposed to has left me a bit underwhelmed. I am pretty hesitant to add something I will need to maintain that I don't necessary understand. Based on that first link, it sounds like this fragment has been created and published. Is there some reason that the other library can't be used? |
Thanks for the quick reaction. I would prefer that the "real source" of the Liquibase-SLF4J bridge would support both basic Java runtimes and modular ones. But if you prefer I can either contact them to ask them to upgrade, or maintain my own fork independently? |
@erwindl0 I was able to generate this manifest with BND. Will this work?
|
I published a snapshot with the generated manifest. Let me know if it works for you. |
Hello guys,
I'll let you know if I find more information about this issue. |
Thanks for the report. I don't know too much about OSGi so any assistance would be appreciated. Do you have a stacktrace for the error? That will help pinpoint where in Liquibase its having issues. The "Cannot find default log service" usually means something is trying to load the service before the scope is fully active in Liquibase. I also know that Liquibase frequently breaks OSGi support. I think they just fixed something else in 4.7.1 so I would try an updated version. Lastly, I don't have an example project using OSGi so if you one or have pointers on how to set one up, that would be greatly appreciated. |
I'm quite busy those days but here is already some information, I'll try to expand asap. The following stacktrace is displayed during the connection pre-hook. This hook is called during the datasource creation, before it is available for services trying to inject it.
Here is the PreHook :
I can later provide you a repository with a simple example to reproduce. |
I've published another snapshot to maven central snapshots. I've added the following to my manifest:
I realized that I wasn't exposing the JDK |
Hi @mattbertolini , Of course, I were not further in the process and there will maybe an other issue with Liquibase during the migration once the logging issue is solved, so don't be surprised if the script isn't applied to the database. https://github.com/gmilani/karaf-liquibase-logging Don't hesitate to ask if I can help you, having your library running on OSGi would be a really valuable achievement for me. |
Thanks @gmilani. This is very helpful. Are we sure that Liquibase works without the slfj4j jar? I ask because even if slfj4j isn't found from the bundle the default logger should be found and it is not. I am not sure the version of Liquibase used (4.4.x) is working with OSGi. Getting it to work without the slf4j logging bridge jar is the first step to knowing what's going on. |
Hi all, Sorry I have not been active in helping out on this. But just a rapid confirmation: When you run liquibase(4.4.3 in my case) in an OSGi container (Equinox in my case), it does work. The result of mixed logging (Slf4j for everything except Liquibase; java.util.loggin for Liquibase) is similar to below: With a correctly built liquibase-slf4j fragment, we get a single integrated slf4j-based log as below.
regards erwin |
I just checked with your snapshot jar and in my osgi application/platform it does seem to work. I.e. I get the right integrated logging. id State Bundle |
That good to hear @erwindl0 . Thanks for taking a look. Based on the available information, I'm inclined to believe the manifest is correct and there is something else wrong with either Liquibase or the example. @gmilani I tried running the provided example without liquibase-slf4j to see if it didn't throw the I noticed that the example doesn't use the private void prepare(Connection connection) throws LiquibaseException {
OSGiResourceAccessor resourceAccessor = new OSGiResourceAccessor(bundle);
try (Liquibase liquibase = new Liquibase("migrations.xml", resourceAccessor, new JdbcConnection(connection))) {
liquibase.update(new Contexts());
}
} Given @erwindl0's information, I might move ahead with publishing what I have on branch gen-osgi-bundle-bnd. Let me know your thoughts. Thanks. |
I wasn't able to validate the OSGi metadata with version 4.1.0 of Liquibase. The only version I was able to validate it with was the latest version (4.9.1). I believe this is because of various issues with the Liquibase OSGi metadata (liquibase/liquibase#2361). I also needed to add some additional bundles to the example application that @gmilani sent me. Liquibase requires the following capabilities:
Those needed to work in order for the ServiceLoader to load the logging configuration. I have updated liquibase-slf4j with this information and published version 4.1.0 with OSGi metadata. I am considering this issue closed. |
In an OSGi runtime we also would like to bridge Liquibase 4.x's logging to SLF4J.
To get this working, Liquibase-SLF4J should be packaged as a fragment, with Liquibase core as the host bundle.
Then the Slf4JLogService can be discovered by Liquibase's ServiceLocator.
Cfr ongoing work and discussions:
I propose to prepare a PR for this?
The text was updated successfully, but these errors were encountered: