You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2017/05/26 16:33:17 UTC

Experiences with karaf and liquibase?

Are there anyone on this list who has any experience with liquibase[1]
in karaf applications?

Liquibase is a pretty neat solution to the issue of database schema
versioning, and putting the same schema on different RDBMSes.

But it has some quirks, notably a strange approach to logging[2].

I've had partial success with replacing the logger: replacing the logger
works in the unit test, but not when running in OSGi (the logger isn
replaced in he pax exam tests, nor is the logger replaced when running
in karaf)[3].

Has anyone else had success with replacing the liquibase logger in
karaf?

Thanks!


 - Steinar


[1] <http://www.liquibase.org>
[2] <http://www.bennybottema.com/2013/12/29/fixing-liquibase-logging-in-spring/>
[3] <http://forum.liquibase.org/topic/unable-to-replace-logger-servicelocator-instance-returns-null#49382000001676011>


Re: Experiences with karaf and liquibase?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Christian Schneider <ch...@die-schneider.net>:

> Sounds great. Can you also open issues for what you found and changed at
> liquibase? Maybe we can persuade them to deliver the necesary changes
> themselves.

There already are existing liquibase issues on the logging issue:
 https://liquibase.jira.com/browse/CORE-39
 https://liquibase.jira.com/browse/CORE-2389
 https://liquibase.jira.com/browse/CORE-2083
 https://liquibase.jira.com/browse/CORE-2492

CORE-2038 is replacing the proprietary logging with slf4j and it is a
stated goal for liquibase 4.0[1]

I have made a comment on CORE-2038[3].

Unfortunately, looking at the github state of the 4.0.x branch of
liquibase[2], there has been no activity for two years.  Instead the
work has focused on the 3.x releases (which has the old logging in
place).

FWIW apart from the logging annoyance, liquibase is great.  I was able
to replace a lot of code from setup of tests using the derby database,
all of my database setup code for the derby database, easily set up the
same schema in both derby and postgres, and automate manual setup of
initial values in the postgresql database (creating an admin user and
some initial task types).

(And I got to that point in a day or three... then spent over a week
trying to avoid having the karaf console flooded with log messages...)

References:
[1] <http://www.bennybottema.com/2013/12/29/fixing-liquibase-logging-in-spring/#comment-232>
[2] <https://github.com/liquibase/liquibase/tree/4.0.x/liquibase-core>
[3] <https://liquibase.jira.com/browse/CORE-2083?focusedCommentId=41201&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-41201>


Re: Experiences with karaf and liquibase?

Posted by Christian Schneider <ch...@die-schneider.net>.
Sounds great. Can you also open issues for what you found and changed at
liquibase? Maybe we can persuade them to deliver the necesary changes
themselves.

Christian

2017-06-02 23:24 GMT+02:00 Steinar Bang <sb...@dod.no>:

> >>>>> Steinar Bang <sb...@dod.no>:
>
> >>>>> Hello Steinar! I'm using liquibase in karaf for some time, and to
> >>>>> fix that you need to repackage the liquibase-slf4j for it to be a
> >>>>> fragment of the liquibase bundle. Here's how:
>
> >>>>> https://gist.github.com/YgorCastor/44fb3a13520d28aa328c4975f8bf5e8c
>
> >>>>> and in your feature:
>
> >>>>> <feature name="liquibase" description="OSGiFied Liquibase"
> start-level="40" version="3.5.1">
> >>>>> <bundle>mvn:org.liquibase/liquibase-core/3.5.1</bundle>
> >>>>> <bundle>mvn:org.yaml/snakeyaml/1.17</bundle>
> >>>>> <bundle start-level="35">mvn:com.mattbertolini/liquibase-slf4j-
> osgi/2.0.0</bundle>
> >>>>> </feature>
>
> > I was thinking "attach to the bundle using liquibase", so that was what
> > I read...
>
> > But what you clearly say here is: "attach to the org.liquibase.core
> > bundle". :-)
>
> > When I followed your instructions, and:
> >  - Created a maven module that rebundled the liquibase-slf4j jar into an
> >    OSGi bundle fragment (as outlined in your gist)
> >  - Modified the feature.xml file as outlined in the quoted file above
> >    (the start levels are important)
>
> > I have some modifications to the bundling compared to the gist.  I will
> > post a followup to this article with a link to the code, when I
> > eventually push the liquibase changes.
>
> I've now pushed the liquibase changes to this branch (including the
> liquibase-slf4j based logging):
>  https://github.com/steinarb/ukelonn/tree/work/use-liquibase
>
> The liquibase-slf4j changes was made in this commit:
>  https://github.com/steinarb/ukelonn/commit/1a85c03fe00e63b5ecbdbb507dae9b
> 3b53cb68e7
>
> I've also created a standalone liqibase-core feature for karaf:
>  https://github.com/steinarb/liquibase-karaf-feature
>
>


-- 
-- 
Christian Schneider
http://www.liquid-reality.de
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.liquid-reality.de>

Open Source Architect
http://www.talend.com
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.talend.com>

Re: Experiences with karaf and liquibase?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

>>>>> Hello Steinar! I'm using liquibase in karaf for some time, and to
>>>>> fix that you need to repackage the liquibase-slf4j for it to be a
>>>>> fragment of the liquibase bundle. Here's how:

>>>>> https://gist.github.com/YgorCastor/44fb3a13520d28aa328c4975f8bf5e8c

>>>>> and in your feature:

>>>>> <feature name="liquibase" description="OSGiFied Liquibase" start-level="40" version="3.5.1">
>>>>> <bundle>mvn:org.liquibase/liquibase-core/3.5.1</bundle>
>>>>> <bundle>mvn:org.yaml/snakeyaml/1.17</bundle>
>>>>> <bundle start-level="35">mvn:com.mattbertolini/liquibase-slf4j-osgi/2.0.0</bundle>
>>>>> </feature>

> I was thinking "attach to the bundle using liquibase", so that was what
> I read...

> But what you clearly say here is: "attach to the org.liquibase.core
> bundle". :-)

> When I followed your instructions, and:
>  - Created a maven module that rebundled the liquibase-slf4j jar into an
>    OSGi bundle fragment (as outlined in your gist)
>  - Modified the feature.xml file as outlined in the quoted file above
>    (the start levels are important)

> I have some modifications to the bundling compared to the gist.  I will
> post a followup to this article with a link to the code, when I
> eventually push the liquibase changes.

I've now pushed the liquibase changes to this branch (including the
liquibase-slf4j based logging):
 https://github.com/steinarb/ukelonn/tree/work/use-liquibase

The liquibase-slf4j changes was made in this commit:
 https://github.com/steinarb/ukelonn/commit/1a85c03fe00e63b5ecbdbb507dae9b3b53cb68e7

I've also created a standalone liqibase-core feature for karaf:
 https://github.com/steinarb/liquibase-karaf-feature


Re: Weird behaviour when uninstalling feature with fragment

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

>>>>> Steinar Bang <sb...@dod.no>:
>>>>> Castor <yg...@gmail.com>:
>>> That's weird, i'm using the liquibase-slf4j as a fragment for quite
>>> sometime and i don't have this problem. but i'm using Karaf 4.0.8, and
>>> if i'm correct karaf 4.1.x changed some stuff related to logging,
>>> could be the cause of the problem.

>> Could be...? 

>> Should this be reported as a karaf bug?  It should be pretty easy to
>> create a test case (just a maven file or two, to rebundle
>> liquibase-slf4j and create a karaf feature).

> Here's the testcase:
>  https://github.com/steinarb/liquibase-karaf-feature

Here's the bug: https://issues.apache.org/jira/browse/KARAF-5174


Re: Weird behaviour when uninstalling feature with fragment

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

>>>>> Castor <yg...@gmail.com>:
>> That's weird, i'm using the liquibase-slf4j as a fragment for quite
>> sometime and i don't have this problem. but i'm using Karaf 4.0.8, and
>> if i'm correct karaf 4.1.x changed some stuff related to logging,
>> could be the cause of the problem.

> Could be...? 

> Should this be reported as a karaf bug?  It should be pretty easy to
> create a test case (just a maven file or two, to rebundle
> liquibase-slf4j and create a karaf feature).

Here's the testcase:
 https://github.com/steinarb/liquibase-karaf-feature

Actually the above project doubles fine as a what the README says what
it is, if you don't try uninstalling it...;-)

The readme says: This project contains a karaf feature for easily using
Liquibase from OSGi-based applications running in apache karaf.

Karaf 4.0.7 and 4.0.9 don't have the uninstalling issue.


Re: Weird behaviour when uninstalling feature with fragment

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Castor <yg...@gmail.com>:

> That's weird, i'm using the liquibase-slf4j as a fragment for quite
> sometime and i don't have this problem. but i'm using Karaf 4.0.8, and
> if i'm correct karaf 4.1.x changed some stuff related to logging,
> could be the cause of the problem.

Could be...? 

Should this be reported as a karaf bug?  It should be pretty easy to
create a test case (just a maven file or two, to rebundle
liquibase-slf4j and create a karaf feature).

> Well, instead using the liquibase-slf4j as a fragment you can also
> repackage the liquibase bundle and add to it's header the
> liquibase.ext.logging to his Import-Package with an optional resolver,
> so when you install the liquibase-slf4j as a bundle ( not a fragment )
> it will work. But i'm not sure it will solve the problem.

Yes, I think that for this to solve the problem I would have to hook up
to an activator that manipulate the logger used by, and specifically
unregister/release the logger on bundle shutdown.


Re: Weird behaviour when uninstalling feature with fragment

Posted by Castor <yg...@gmail.com>.
That's weird, i'm using the liquibase-slf4j as a fragment for quite sometime
and i don't have this problem. but i'm using Karaf 4.0.8, and if i'm correct
karaf 4.1.x changed some stuff related to logging,  could be the cause of
the problem. 

Well, instead using the liquibase-slf4j as a fragment you can also repackage
the liquibase bundle and add to it's header the liquibase.ext.logging to his
Import-Package with an optional resolver, so when you install the
liquibase-slf4j as a bundle ( not a fragment ) it will work. But i'm not
sure it will solve the problem. 



--
View this message in context: http://karaf.922171.n3.nabble.com/Experiences-with-karaf-and-liquibase-tp4050470p4050503.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Weird behaviour when uninstalling feature with fragment

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
>>>>> Achim Nierbeck <bc...@googlemail.com>:

>> But maybe a lib your using might fire this in case of an "error".

> This could be it.

> The problem bundle is an OSGi bundle fragment made from the
> liquibase-slf4j maven dependency[1], as outlined in
>  http://karaf.922171.n3.nabble.com/Experiences-with-karaf-and-liquibase-tp4050470p4050471.html

> Could it be that something strange happens with slf4j when the fragment
> is uninstalled, and that this is what kills karaf...?

> [1] <https://github.com/mattbertolini/liquibase-slf4j>

I did another experiment: I made the fragment bundle be empty (ie. made
a bundle without any code).  And that bundle could be uninstalled
without getting an error message.

So the best guess is that there is something in this code that gives a
problem when the bundle is yanked:
 https://github.com/mattbertolini/liquibase-slf4j/blob/master/src/main/java/liquibase/ext/logging/slf4j/Slf4jLogger.java


Re: Weird behaviour when uninstalling feature with fragment

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

>>>>> Achim Nierbeck <bc...@googlemail.com>:
>> Not sure, but at first glance this reminds me of a system.exit
>> somewhere in the code.  May it be that something in your code fires
>> this on a "change" or Bundle stop?

> My own code, by itself does not trigger this issue.
> I tried various things by elimination, and it's the introduction of the
> fragment bundle that is the problem.

I've found a workaround: if I install the liquibase-core feature
explictly, instead of pulling it in as a dependency of my own feature,
it isn't uninstalled when I uninstall my feature.

Specifically if I replace this in my README[1]
      feature:install ukelonn-db-derby
      feature:install ukelonn

with this:
      feature:install liquibase-core
      feature:install ukelonn-db-derby
      feature:install ukelonn

then I can "feature:uninstall ukelonn-db-derby" without it bringing down
karaf.

[1] <https://github.com/steinarb/ukelonn/blob/master/README.org#utsjekk-og-bygg>


Re: Weird behaviour when uninstalling feature with fragment

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Achim Nierbeck <bc...@googlemail.com>:

> Not sure, but at first glance this reminds me of a system.exit
> somewhere in the code.  May it be that something in your code fires
> this on a "change" or Bundle stop?

My own code, by itself does not trigger this issue.
I tried various things by elimination, and it's the introduction of the
fragment bundle that is the problem.

> But maybe a lib your using might fire this in case of an "error".

This could be it.

The problem bundle is an OSGi bundle fragment made from the
liquibase-slf4j maven dependency[1], as outlined in
 http://karaf.922171.n3.nabble.com/Experiences-with-karaf-and-liquibase-tp4050470p4050471.html

Could it be that something strange happens with slf4j when the fragment
is uninstalled, and that this is what kills karaf...?

[1] <https://github.com/mattbertolini/liquibase-slf4j>


Re: Weird behaviour when uninstalling feature with fragment

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi Steinar ...

Not sure, but at first glance this reminds me of a system.exit somewhere in
the code.
May it be that something in your code fires this on a "change" or Bundle
stop?
But maybe a lib your using might fire this in case of an "error".

regards, Achim

2017-05-29 21:19 GMT+02:00 Steinar Bang <sb...@dod.no>:

> >>>>> Steinar Bang <sb...@dod.no>:
>
> > When I followed your instructions, and:
> >  - Created a maven module that rebundled the liquibase-slf4j jar into an
> >    OSGi bundle fragment (as outlined in your gist)
> >  - Modified the feature.xml file as outlined in the quoted file above
> >    (the start levels are important)
>
> It works: ie. the feature installs, and liquibase output ends up in
> karaf.log.
>
> However, when I uninstall the feature containing the fragment, karaf
> itself shuts down.
>
> Has anyone else seen something similar?
> Is this expected behaviour of fragments?
>
> If I remove the liquibase-slf4j-osgi fragment OSGi bundle from the
> feature, then liquibase output ends up on the karaf console, but there
> are no strange side effects from uninstalling the feature.
>
> Here's karaf.log output from the shutdown that happens caused by feature
> uninstall (the unexpected stuff is from "2017-05-28T23:30:02,177"
> ("FelixShutdown"):
>
> 2017-05-28T23:30:01,840 | INFO  | pipe-feature:install
> ukelonn-db-derby-test | FeaturesServiceImpl              | 9 -
> org.apache.karaf.features.core - 4.1.1 | Removing features:
> feature:ukelonn-db-derby-test/[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]
> 2017-05-28T23:30:02,040 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 | Changes to
> perform:
> 2017-05-28T23:30:02,040 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |   Region: root
> 2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |     Bundles to
> uninstall:
> 2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  derby/10.11.1000001.1616546
> 2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.api/1.0.0.SNAPSHOT
> 2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.db.liquibase/1.0.0.SNAPSHOT
> 2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.db.test/1.0.0.SNAPSHOT
> 2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.rebundled.liquibase-slf4j-osgi/2.0.0
> 2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.liquibase.core/3.5.3
> 2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.base.spi/1.5.0
> 2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.pax.jdbc/1.0.1
> 2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.pax.jdbc.derby/1.0.1
> 2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.osgi.service.jdbc/1.0.0.201505202023
> 2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.yaml.snakeyaml/1.17.0
> 2017-05-28T23:30:02,043 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 | Stopping bundles:
> 2017-05-28T23:30:02,045 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.yaml.snakeyaml/1.17.0
> 2017-05-28T23:30:02,046 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.osgi.service.jdbc/1.0.0.201505202023
> 2017-05-28T23:30:02,046 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.pax.jdbc/1.0.1
> 2017-05-28T23:30:02,049 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.base.spi/1.5.0
> 2017-05-28T23:30:02,049 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.liquibase.core/3.5.3
> 2017-05-28T23:30:02,050 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.db.test/1.0.0.SNAPSHOT
> 2017-05-28T23:30:02,051 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.db.liquibase/1.0.0.SNAPSHOT
> 2017-05-28T23:30:02,052 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.api/1.0.0.SNAPSHOT
> 2017-05-28T23:30:02,052 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.pax.jdbc.derby/1.0.1
> 2017-05-28T23:30:02,054 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  derby/10.11.1000001.1616546
> 2017-05-28T23:30:02,078 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 | Uninstalling
> bundles:
> 2017-05-28T23:30:02,079 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  derby/10.11.1000001.1616546
> 2017-05-28T23:30:02,084 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.api/1.0.0.SNAPSHOT
> 2017-05-28T23:30:02,089 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.db.liquibase/1.0.0.SNAPSHOT
> 2017-05-28T23:30:02,094 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.db.test/1.0.0.SNAPSHOT
> 2017-05-28T23:30:02,113 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.rebundled.liquibase-slf4j-osgi/2.0.0
> 2017-05-28T23:30:02,118 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.liquibase.core/3.5.3
> 2017-05-28T23:30:02,123 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.base.spi/1.5.0
> 2017-05-28T23:30:02,128 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.pax.jdbc/1.0.1
> 2017-05-28T23:30:02,138 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.pax.jdbc.derby/1.0.1
> 2017-05-28T23:30:02,150 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.osgi.service.jdbc/1.0.0.201505202023
> 2017-05-28T23:30:02,158 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.yaml.snakeyaml/1.17.0
> 2017-05-28T23:30:02,168 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 | Refreshing
> bundles:
> 2017-05-28T23:30:02,168 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  derby/10.11.1000001.1616546 (Bundle will be uninstalled)
> 2017-05-28T23:30:02,168 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.api/1.0.0.SNAPSHOT (Bundle will be uninstalled)
> 2017-05-28T23:30:02,168 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.db.liquibase/1.0.0.SNAPSHOT (Bundle will be
> uninstalled)
> 2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.db.test/1.0.0.SNAPSHOT (Bundle will be uninstalled)
> 2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  no.priv.bang.ukelonn.rebundled.liquibase-slf4j-osgi/2.0.0 (Bundle will
> be uninstalled)
> 2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.liquibase.core/3.5.3 (Bundle will be uninstalled)
> 2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.base.spi/1.5.0 (Bundle will be uninstalled)
> 2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.pax.jdbc/1.0.1 (Bundle will be uninstalled)
> 2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.ops4j.pax.jdbc.derby/1.0.1 (Bundle will be uninstalled)
> 2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.osgi.service.jdbc/1.0.0.201505202023 (Bundle will be uninstalled)
> 2017-05-28T23:30:02,170 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 |
>  org.yaml.snakeyaml/1.17.0 (Bundle will be uninstalled)
> 2017-05-28T23:30:02,177 | INFO  | pool-3-thread-1  | FeaturesServiceImpl
>             | 9 - org.apache.karaf.features.core - 4.1.1 | Done.
> 2017-05-28T23:30:02,177 | INFO  | FelixShutdown    | BlueprintExtender
>             | 12 - org.apache.aries.blueprint.core - 1.8.0 | Destroying
> BlueprintContainer for bundle org.apache.karaf.shell.core/4.1.1
> 2017-05-28T23:30:02,186 | INFO  | FelixShutdown    | BlueprintExtender
>             | 12 - org.apache.aries.blueprint.core - 1.8.0 | Destroying
> BlueprintContainer for bundle org.apache.karaf.jaas.blueprint.config/4.1.1
> 2017-05-28T23:30:02,191 | INFO  | FelixShutdown    | BlueprintExtender
>             | 12 - org.apache.aries.blueprint.core - 1.8.0 | Destroying
> BlueprintContainer for bundle org.apache.aries.blueprint.cm/1.1.0
> 2017-05-28T23:30:02,197 | INFO  | FelixShutdown    | BlueprintExtender
>             | 12 - org.apache.aries.blueprint.core - 1.8.0 | Destroying
> BlueprintContainer for bundle org.apache.aries.blueprint.core/1.8.0
> 2017-05-28T23:30:02,210 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.event/4.1.1
> 2017-05-28T23:30:02,213 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.system.core/4.1.1
> 2017-05-28T23:30:02,218 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.shell.ssh/4.1.1
> 2017-05-28T23:30:02,233 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.kar.core/4.1.1
> 2017-05-28T23:30:02,234 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.diagnostic.core/4.1.1
> 2017-05-28T23:30:02,234 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.package.core/4.1.1
> 2017-05-28T23:30:02,235 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.shell.commands/4.1.1
> 2017-05-28T23:30:02,235 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.deployer.kar/4.1.1
> 2017-05-28T23:30:02,236 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.features.command/4.1.1
> 2017-05-28T23:30:02,238 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.service.core/4.1.1
> 2017-05-28T23:30:02,238 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.bundle.core/4.1.1
> 2017-05-28T23:30:02,239 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.config.core/4.1.1
> 2017-05-28T23:30:02,242 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.jaas.command/4.1.1
> 2017-05-28T23:30:02,244 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.instance.core/4.1.1
> 2017-05-28T23:30:02,244 | INFO  | FelixStartLevel  | CommandExtension
>            | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering
> commands for bundle org.apache.karaf.log.core/4.1.1
> 2017-05-28T23:30:02,254 | INFO  | FelixStartLevel  | core
>            | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering
> org.osgi.jmx.service.cm.ConfigurationAdminMBean to MBeanServer
> com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name
> osgi.compendium:service=cm,version=1.3,framework=org.
> apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
> 2017-05-28T23:30:02,255 | INFO  | FelixStartLevel  | core
>            | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering
> org.osgi.jmx.framework.ServiceStateMBean to MBeanServer
> com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name
> osgi.core:type=serviceState,version=1.7,framework=org.
> apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
> 2017-05-28T23:30:02,256 | INFO  | FelixStartLevel  | core
>            | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering
> org.osgi.jmx.framework.BundleStateMBean to MBeanServer
> com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name
> osgi.core:type=bundleState,version=1.7,framework=org.
> apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
> 2017-05-28T23:30:02,256 | INFO  | FelixStartLevel  | core
>            | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering
> org.osgi.jmx.framework.wiring.BundleWiringStateMBean to MBeanServer
> com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name
> osgi.core:type=wiringState,version=1.1,framework=org.
> apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
> 2017-05-28T23:30:02,256 | INFO  | FelixStartLevel  | core
>            | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering
> org.osgi.jmx.framework.FrameworkMBean to MBeanServer
> com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name
> osgi.core:type=framework,version=1.7,framework=org.
> apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
> 2017-05-28T23:30:02,257 | INFO  | FelixStartLevel  | core
>            | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering
> org.osgi.jmx.framework.PackageStateMBean to MBeanServer
> com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name
> osgi.core:type=packageState,version=1.5,framework=org.
> apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
> 2017-05-28T23:30:02,258 | WARN  | FelixStartLevel  | core
>            | 16 - org.apache.aries.jmx.core - 1.1.7 | Task rejected for JMX
> Notification dispatch of event [org.osgi.framework.
> ServiceEvent[source=[javax.management.MBeanServer]]] - Dispatcher may
> have been shutdown
> 2017-05-28T23:30:02,286 | INFO  | FelixStartLevel  | core
>            | 16 - org.apache.aries.jmx.core - 1.1.7 | Stopping JMX OSGi
> agent
> 2017-05-28T23:30:02,287 | INFO  | FelixStartLevel  | core
>            | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering MBean
> with ObjectName [osgi.compendium:service=cm,version=1.3,framework=org.
> apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d] for
> service with service.id [12]
> mai 28, 2017 11:30:02 PM org.apache.karaf.main.lock.SimpleFileLock lock
> INFO: Trying to lock C:\ProgramFiles\apache-karaf-4.1.1\lock
> mai 28, 2017 11:30:02 PM org.apache.karaf.main.lock.SimpleFileLock lock
> INFO: Lock acquired
>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Weird behaviour when uninstalling feature with fragment

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> When I followed your instructions, and:
>  - Created a maven module that rebundled the liquibase-slf4j jar into an
>    OSGi bundle fragment (as outlined in your gist)
>  - Modified the feature.xml file as outlined in the quoted file above
>    (the start levels are important)

It works: ie. the feature installs, and liquibase output ends up in
karaf.log.

However, when I uninstall the feature containing the fragment, karaf
itself shuts down.

Has anyone else seen something similar?
Is this expected behaviour of fragments?

If I remove the liquibase-slf4j-osgi fragment OSGi bundle from the
feature, then liquibase output ends up on the karaf console, but there
are no strange side effects from uninstalling the feature.

Here's karaf.log output from the shutdown that happens caused by feature
uninstall (the unexpected stuff is from "2017-05-28T23:30:02,177"
("FelixShutdown"): 

2017-05-28T23:30:01,840 | INFO  | pipe-feature:install ukelonn-db-derby-test | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 | Removing features: feature:ukelonn-db-derby-test/[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]
2017-05-28T23:30:02,040 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 | Changes to perform:
2017-05-28T23:30:02,040 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   Region: root
2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     Bundles to uninstall:
2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |       derby/10.11.1000001.1616546
2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |       no.priv.bang.ukelonn.api/1.0.0.SNAPSHOT
2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |       no.priv.bang.ukelonn.db.liquibase/1.0.0.SNAPSHOT
2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |       no.priv.bang.ukelonn.db.test/1.0.0.SNAPSHOT
2017-05-28T23:30:02,041 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |       no.priv.bang.ukelonn.rebundled.liquibase-slf4j-osgi/2.0.0
2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |       org.liquibase.core/3.5.3
2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |       org.ops4j.base.spi/1.5.0
2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |       org.ops4j.pax.jdbc/1.0.1
2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |       org.ops4j.pax.jdbc.derby/1.0.1
2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |       org.osgi.service.jdbc/1.0.0.201505202023
2017-05-28T23:30:02,042 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |       org.yaml.snakeyaml/1.17.0
2017-05-28T23:30:02,043 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 | Stopping bundles:
2017-05-28T23:30:02,045 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.yaml.snakeyaml/1.17.0
2017-05-28T23:30:02,046 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.osgi.service.jdbc/1.0.0.201505202023
2017-05-28T23:30:02,046 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.ops4j.pax.jdbc/1.0.1
2017-05-28T23:30:02,049 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.ops4j.base.spi/1.5.0
2017-05-28T23:30:02,049 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.liquibase.core/3.5.3
2017-05-28T23:30:02,050 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   no.priv.bang.ukelonn.db.test/1.0.0.SNAPSHOT
2017-05-28T23:30:02,051 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   no.priv.bang.ukelonn.db.liquibase/1.0.0.SNAPSHOT
2017-05-28T23:30:02,052 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   no.priv.bang.ukelonn.api/1.0.0.SNAPSHOT
2017-05-28T23:30:02,052 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.ops4j.pax.jdbc.derby/1.0.1
2017-05-28T23:30:02,054 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   derby/10.11.1000001.1616546
2017-05-28T23:30:02,078 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 | Uninstalling bundles:
2017-05-28T23:30:02,079 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   derby/10.11.1000001.1616546
2017-05-28T23:30:02,084 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   no.priv.bang.ukelonn.api/1.0.0.SNAPSHOT
2017-05-28T23:30:02,089 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   no.priv.bang.ukelonn.db.liquibase/1.0.0.SNAPSHOT
2017-05-28T23:30:02,094 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   no.priv.bang.ukelonn.db.test/1.0.0.SNAPSHOT
2017-05-28T23:30:02,113 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   no.priv.bang.ukelonn.rebundled.liquibase-slf4j-osgi/2.0.0
2017-05-28T23:30:02,118 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.liquibase.core/3.5.3
2017-05-28T23:30:02,123 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.ops4j.base.spi/1.5.0
2017-05-28T23:30:02,128 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.ops4j.pax.jdbc/1.0.1
2017-05-28T23:30:02,138 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.ops4j.pax.jdbc.derby/1.0.1
2017-05-28T23:30:02,150 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.osgi.service.jdbc/1.0.0.201505202023
2017-05-28T23:30:02,158 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |   org.yaml.snakeyaml/1.17.0
2017-05-28T23:30:02,168 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 | Refreshing bundles:
2017-05-28T23:30:02,168 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     derby/10.11.1000001.1616546 (Bundle will be uninstalled)
2017-05-28T23:30:02,168 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     no.priv.bang.ukelonn.api/1.0.0.SNAPSHOT (Bundle will be uninstalled)
2017-05-28T23:30:02,168 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     no.priv.bang.ukelonn.db.liquibase/1.0.0.SNAPSHOT (Bundle will be uninstalled)
2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     no.priv.bang.ukelonn.db.test/1.0.0.SNAPSHOT (Bundle will be uninstalled)
2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     no.priv.bang.ukelonn.rebundled.liquibase-slf4j-osgi/2.0.0 (Bundle will be uninstalled)
2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     org.liquibase.core/3.5.3 (Bundle will be uninstalled)
2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     org.ops4j.base.spi/1.5.0 (Bundle will be uninstalled)
2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     org.ops4j.pax.jdbc/1.0.1 (Bundle will be uninstalled)
2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     org.ops4j.pax.jdbc.derby/1.0.1 (Bundle will be uninstalled)
2017-05-28T23:30:02,169 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     org.osgi.service.jdbc/1.0.0.201505202023 (Bundle will be uninstalled)
2017-05-28T23:30:02,170 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 |     org.yaml.snakeyaml/1.17.0 (Bundle will be uninstalled)
2017-05-28T23:30:02,177 | INFO  | pool-3-thread-1  | FeaturesServiceImpl              | 9 - org.apache.karaf.features.core - 4.1.1 | Done.
2017-05-28T23:30:02,177 | INFO  | FelixShutdown    | BlueprintExtender                | 12 - org.apache.aries.blueprint.core - 1.8.0 | Destroying BlueprintContainer for bundle org.apache.karaf.shell.core/4.1.1
2017-05-28T23:30:02,186 | INFO  | FelixShutdown    | BlueprintExtender                | 12 - org.apache.aries.blueprint.core - 1.8.0 | Destroying BlueprintContainer for bundle org.apache.karaf.jaas.blueprint.config/4.1.1
2017-05-28T23:30:02,191 | INFO  | FelixShutdown    | BlueprintExtender                | 12 - org.apache.aries.blueprint.core - 1.8.0 | Destroying BlueprintContainer for bundle org.apache.aries.blueprint.cm/1.1.0
2017-05-28T23:30:02,197 | INFO  | FelixShutdown    | BlueprintExtender                | 12 - org.apache.aries.blueprint.core - 1.8.0 | Destroying BlueprintContainer for bundle org.apache.aries.blueprint.core/1.8.0
2017-05-28T23:30:02,210 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.event/4.1.1
2017-05-28T23:30:02,213 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.system.core/4.1.1
2017-05-28T23:30:02,218 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.shell.ssh/4.1.1
2017-05-28T23:30:02,233 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.kar.core/4.1.1
2017-05-28T23:30:02,234 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.diagnostic.core/4.1.1
2017-05-28T23:30:02,234 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.package.core/4.1.1
2017-05-28T23:30:02,235 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.shell.commands/4.1.1
2017-05-28T23:30:02,235 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.deployer.kar/4.1.1
2017-05-28T23:30:02,236 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.features.command/4.1.1
2017-05-28T23:30:02,238 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.service.core/4.1.1
2017-05-28T23:30:02,238 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.bundle.core/4.1.1
2017-05-28T23:30:02,239 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.config.core/4.1.1
2017-05-28T23:30:02,242 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.jaas.command/4.1.1
2017-05-28T23:30:02,244 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.instance.core/4.1.1
2017-05-28T23:30:02,244 | INFO  | FelixStartLevel  | CommandExtension                 | 42 - org.apache.karaf.shell.core - 4.1.1 | Unregistering commands for bundle org.apache.karaf.log.core/4.1.1
2017-05-28T23:30:02,254 | INFO  | FelixStartLevel  | core                             | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering org.osgi.jmx.service.cm.ConfigurationAdminMBean to MBeanServer com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name osgi.compendium:service=cm,version=1.3,framework=org.apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
2017-05-28T23:30:02,255 | INFO  | FelixStartLevel  | core                             | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering org.osgi.jmx.framework.ServiceStateMBean to MBeanServer com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name osgi.core:type=serviceState,version=1.7,framework=org.apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
2017-05-28T23:30:02,256 | INFO  | FelixStartLevel  | core                             | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering org.osgi.jmx.framework.BundleStateMBean to MBeanServer com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name osgi.core:type=bundleState,version=1.7,framework=org.apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
2017-05-28T23:30:02,256 | INFO  | FelixStartLevel  | core                             | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering org.osgi.jmx.framework.wiring.BundleWiringStateMBean to MBeanServer com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name osgi.core:type=wiringState,version=1.1,framework=org.apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
2017-05-28T23:30:02,256 | INFO  | FelixStartLevel  | core                             | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering org.osgi.jmx.framework.FrameworkMBean to MBeanServer com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name osgi.core:type=framework,version=1.7,framework=org.apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
2017-05-28T23:30:02,257 | INFO  | FelixStartLevel  | core                             | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering org.osgi.jmx.framework.PackageStateMBean to MBeanServer com.sun.jmx.mbeanserver.JmxMBeanServer@67117f44 with name osgi.core:type=packageState,version=1.5,framework=org.apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d
2017-05-28T23:30:02,258 | WARN  | FelixStartLevel  | core                             | 16 - org.apache.aries.jmx.core - 1.1.7 | Task rejected for JMX Notification dispatch of event [org.osgi.framework.ServiceEvent[source=[javax.management.MBeanServer]]] - Dispatcher may have been shutdown
2017-05-28T23:30:02,286 | INFO  | FelixStartLevel  | core                             | 16 - org.apache.aries.jmx.core - 1.1.7 | Stopping JMX OSGi agent
2017-05-28T23:30:02,287 | INFO  | FelixStartLevel  | core                             | 16 - org.apache.aries.jmx.core - 1.1.7 | Unregistering MBean with ObjectName [osgi.compendium:service=cm,version=1.3,framework=org.apache.felix.framework,uuid=46d6c27b-ef98-45cb-a32f-36e224a1c18d] for service with service.id [12]
mai 28, 2017 11:30:02 PM org.apache.karaf.main.lock.SimpleFileLock lock
INFO: Trying to lock C:\ProgramFiles\apache-karaf-4.1.1\lock
mai 28, 2017 11:30:02 PM org.apache.karaf.main.lock.SimpleFileLock lock
INFO: Lock acquired


Re: Experiences with karaf and liquibase?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
>>>>> Castor <yg...@gmail.com>:

>> Exactly! It's a classpath problem, liquibase uses a weird approach to swap
>> his crappy log system to use slf4j, it scans a classpath and "swaps" the
>> reference.

> Yes, I know.  I figured it out eventually with the help of this[1].

> Note that in a comment in that article, the liquibase maintainer says
> liquibase 4.0 will support slf4j.  However the 4.0 branch of liquibase
> hasn't been touched for 2 years[2], so that is probably not going to
> happen...?  The most recent work on liquibase has been happening on the
> 3.5 branch, that still uses the proprietary logging.

It's a pity the liquibase 4.0 effort seems to be abandoned.  Among other
things, it had this OSGi bundle with a bundle activator, that hopefully
would have set things up correctly:
 https://github.com/liquibase/liquibase/tree/4.0.x/liquibase-osgi/src/main/java/liquibase/osgi

>> When you install liquibase and liquibase-slf4j as separated bundles,
>> the liquibase bundle does not look for the liquibase-slf4j exported
>> packages, and when you make the liquibase-slf4j a fragment of
>> liquibase, the liquibase bundle can scan the liquibase-slf4j
>> classpath.

> Hm... but by this description my most recent experiment, which is to add
> a package liquibase:ext:logging to the bundle that runs liquibase, and
> add my own subclass of AbstractLogger there, should have worked as
> well...?

Completely wrong!  I was misreading your first reply. :-)

Quoting from the first reply.

>>>> Hello Steinar! I'm using liquibase in karaf for some time, and to
>>>> fix that you need to repackage the liquibase-slf4j for it to be a
>>>> fragment of the liquibase bundle. Here's how:

>>>> https://gist.github.com/YgorCastor/44fb3a13520d28aa328c4975f8bf5e8c

>>>> and in your feature:

>>>> <feature name="liquibase" description="OSGiFied Liquibase" start-level="40" version="3.5.1">
>>>>    <bundle>mvn:org.liquibase/liquibase-core/3.5.1</bundle>
>>>>    <bundle>mvn:org.yaml/snakeyaml/1.17</bundle>
>>>>    <bundle start-level="35">mvn:com.mattbertolini/liquibase-slf4j-osgi/2.0.0</bundle>
>>>> </feature>

I was thinking "attach to the bundle using liquibase", so that was what
I read...

But what you clearly say here is: "attach to the org.liquibase.core
bundle". :-)

When I followed your instructions, and:
 - Created a maven module that rebundled the liquibase-slf4j jar into an
   OSGi bundle fragment (as outlined in your gist)
 - Modified the feature.xml file as outlined in the quoted file above
   (the start levels are important)

I have some modifications to the bundling compared to the gist.  I will
post a followup to this article with a link to the code, when I
eventually push the liquibase changes.


Re: Experiences with karaf and liquibase?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Castor <yg...@gmail.com>:

> Exactly! It's a classpath problem, liquibase uses a weird approach to swap
> his crappy log system to use slf4j, it scans a classpath and "swaps" the
> reference.

Yes, I know.  I figured it out eventually with the help of this[1].

Note that in a comment in that article, the liquibase maintainer says
liquibase 4.0 will support slf4j.  However the 4.0 branch of liquibase
hasn't been touched for 2 years[2], so that is probably not going to
happen...?  The most recent work on liquibase has been happening on the
3.5 branch, that still uses the proprietary logging.

> When you install liquibase and liquibase-slf4j as separated bundles,
> the liquibase bundle does not look for the liquibase-slf4j exported
> packages, and when you make the liquibase-slf4j a fragment of
> liquibase, the liquibase bundle can scan the liquibase-slf4j
> classpath.

Hm... but by this description my most recent experiment, which is to add
a package liquibase:ext:logging to the bundle that runs liquibase, and
add my own subclass of AbstractLogger there, should have worked as
well...?

And when I've stopped to think about it, and with the above information
I think I know why it didn't work for me:
 - Right now I'm using liquibase as a library bundle
 - I need to expose my code that uses liquibase as an OSGi service, and
   call that service from the other bundles that use liquibase.

Here's what I've done
 - I have a project that uses this interface as an OSGi service, to be
   able to switch between two database implementations[3]
 - The OSGi service is implemented by a derby test database and a
   postgresql production database
 - I have added a new bundle that
    - Embeds the liquibase changeset for the schema
    - Added a class with a single method that takes a PooledConnection
      argument, and updates the database with the schema from the
      embedded changeset
 - In the bundle that implements the database service for the derby
   database, I do the following at startup, after aquiring a database
   connection: 
    - Create an instance of the class from the new bundle (ie. inside
      the derby database bundle), and use it to create the schema
    - Directly use the liquibase code to run liquibase changesets
      containing test data, that have been embedded in the derby
      database
 - In the bundle that implements database service for the postgresql
   database I create an instance of the class from the new bundle and
   use it to create/update the schema

(I haven't pushed any of the above changes yet. I still keep thinkering
with them.  The annyoing bit here is that it actually works, ie. the
hard part, creating the database schema, works.  But the karaf console
is cluttered by the liquibase logs)

Anyway, what I think I need to do is to make my liquibase schema creator an OSGi
service and call that service from the derby and postgresql bundles.

I will try that.

> This happens quite a lot when you work with libraries that works with
> classpaths and weren't created with osgi in mind, a pain in the a** if you
> ask me.

Agreed! :-/

Thanks for your insights.  They were helpful.

References:
[1} <http://www.bennybottema.com/2013/12/29/fixing-liquibase-logging-in-spring/>
[2} <https://github.com/liquibase/liquibase/tree/4.0.x>
[3} <https://github.com/steinarb/ukelonn/blob/master/ukelonn.api/src/main/java/no/priv/bang/ukelonn/UkelonnDatabase.java>


Re: Experiences with karaf and liquibase?

Posted by Castor <yg...@gmail.com>.
Exactly! It's a classpath problem, liquibase uses a weird approach to swap
his crappy log system to use slf4j, it scans a classpath and "swaps" the
reference. When you install liquibase and liquibase-slf4j as separated
bundles, the liquibase bundle does not look for the liquibase-slf4j
exported packages, and when you make the liquibase-slf4j a fragment of
liquibase, the liquibase bundle can scan the liquibase-slf4j classpath.

This happens quite a lot when you work with libraries that works with
classpaths and weren't created with osgi in mind, a pain in the a** if you
ask me.

Em sex, 26 de mai de 2017 às 16:49, Steinar Bang [via Karaf] <
ml+s922171n4050472h80@n3.nabble.com> escreveu:

> >>>>> Castor <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4050472&i=0>>:
>
> > Hello Steinar! I'm using liquibase in karaf for some time, and to fix
> that
> > you need to repackage the liquibase-slf4j for it to be a fragment of the
> > liquibase bundle. Here's how:
>
> > https://gist.github.com/YgorCastor/44fb3a13520d28aa328c4975f8bf5e8c
> [snip!]
>
> Right! Thanks! Fragments have always been a mystery to me...:-)
> Any idea why thi will work and the more regular OSGi ways don't work?
> Something to do with classloaders...?
>
> > You can also do the same thing using the wrap protocol, without the need
> to
> > repackage liquibase-slf4j, but i remember i had some problems with that,
> i
> > don't recall what happened.
>
> I've tried using the wrap protocol in karaf with the existing
> liquibase-slf4j maven dependency but that didn't work.
>
> And what I have now is similar: I've subclassed AbstractLogger in a
> class residing in package liquibase.ext.logging.
>
> This works in the unit tests, but not in an OSGi context.
>
> The bundle exports the liquibase.ext.logging
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://karaf.922171.n3.nabble.com/Experiences-with-karaf-and-liquibase-tp4050470p4050472.html
> To unsubscribe from Experiences with karaf and liquibase?, click here
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4050470&code=eWdvcmNhc3RvckBnbWFpbC5jb218NDA1MDQ3MHwtMzgxNTQ3NDAw>
> .
> NAML
> <http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://karaf.922171.n3.nabble.com/Experiences-with-karaf-and-liquibase-tp4050470p4050473.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Experiences with karaf and liquibase?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Castor <yg...@gmail.com>:

> Hello Steinar! I'm using liquibase in karaf for some time, and to fix that
> you need to repackage the liquibase-slf4j for it to be a fragment of the
> liquibase bundle. Here's how: 

> https://gist.github.com/YgorCastor/44fb3a13520d28aa328c4975f8bf5e8c
[snip!]

Right! Thanks! Fragments have always been a mystery to me...:-)
Any idea why thi will work and the more regular OSGi ways don't work?
Something to do with classloaders...?

> You can also do the same thing using the wrap protocol, without the need to
> repackage liquibase-slf4j, but i remember i had some problems with that, i
> don't recall what happened. 

I've tried using the wrap protocol in karaf with the existing
liquibase-slf4j maven dependency but that didn't work.

And what I have now is similar: I've subclassed AbstractLogger in a
class residing in package liquibase.ext.logging.

This works in the unit tests, but not in an OSGi context.

The bundle exports the liquibase.ext.logging


Re: Experiences with karaf and liquibase?

Posted by Castor <yg...@gmail.com>.
Hello Steinar! I'm using liquibase in karaf for some time, and to fix that
you need to repackage the liquibase-slf4j for it to be a fragment of the
liquibase bundle. Here's how: 

https://gist.github.com/YgorCastor/44fb3a13520d28aa328c4975f8bf5e8c

and in your feature:

<feature name="liquibase" description="OSGiFied Liquibase" start-level="40"
version="3.5.1">
   <bundle>mvn:org.liquibase/liquibase-core/3.5.1</bundle>
   <bundle>mvn:org.yaml/snakeyaml/1.17</bundle>
   <bundle
start-level="35">mvn:com.mattbertolini/liquibase-slf4j-osgi/2.0.0</bundle>
</feature>

You can also do the same thing using the wrap protocol, without the need to
repackage liquibase-slf4j, but i remember i had some problems with that, i
don't recall what happened. 



--
View this message in context: http://karaf.922171.n3.nabble.com/Experiences-with-karaf-and-liquibase-tp4050470p4050471.html
Sent from the Karaf - User mailing list archive at Nabble.com.