You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Kushal Gautam <ku...@gmail.com> on 2019/07/31 20:45:16 UTC
Flyway and Karaf
Hi,
I am trying to use Flyway in my Karaf instance.
I have prepared a demo to reproduce the error that I have encountered at
https://github.com/cooshal/karaf-flyway.
I am using a custom built karaf distribution.
I have created two different modules inside db-migrations:
1. flyway provider which has implementations to carry out flyway migrations
2. karaf command, which invokes the implementation of flyway provider
bundle.
I tried following:
karaf@root()> dbf:migrate
Error executing command: java.lang.NoClassDefFoundError: Could not
initialize class org.flywaydb.core.Flyway
karaf@root()> log:tail
22:37:11.081 ERROR [Karaf local console user karaf] Exception caught while
executing command
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError:
Could not initialize class org.flywaydb.core.Flyway
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
~[?:?]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:?]
at
org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:829)
~[?:?]
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
~[?:?]
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.lang.NoClassDefFoundError: Could not initialize class
org.flywaydb.core.Flyway
at
com.example.db.migrations.FlywayDBMigrations.migrate(FlywayDBMigrations.java:16)
~[?:?]
at
com.example.flyway.command.MigrateDatabaseCommand.execute(MigrateDatabaseCommand.java:20)
~[?:?]
at
org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
~[?:?]
at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
~[?:?]
at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
~[?:?]
at
org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571) ~[?:?]
at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
~[?:?]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
~[?:?]
at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) ~[?:?]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) ~[?:?]
... 4 more
I am getting this error from
https://github.com/cooshal/karaf-flyway/tree/master/db-migrations/flyway-provider
I also tried installing flyway-core bundle in Karaf, but it did not work. I
got the same error.
Do I need to configure some settings in the pom file of this project? (
https://github.com/cooshal/karaf-flyway/blob/master/db-migrations/flyway-provider/pom.xml
)
Any feedback would be very helpful.
Regards,
Cooshal.
Re: Flyway and Karaf
Posted by Kushal Gautam <ku...@gmail.com>.
Hi again:
I will try this again, with fragment host option. I guess I might have missed something minor. I will get back with results.
Thank you.
Regards,
Cooshal.
Regards,
Kushal.
________________________________
From: Jean-Baptiste Onofré <jb...@nanthrax.net>
Sent: Thursday, August 1, 2019 6:40 AM
To: user@karaf.apache.org
Subject: Re: Flyway and Karaf
Yes, it's what I meant: you have to "gather" the classloaders.
An option to add all flyway bundles as require bundle/private package in
your own bundle. Like this, all will be in your bundle classloader.
Another option is to use fragment with your bundle as host (as a
fragment is just resolved, only the host is started).
Regards
JB
On 01/08/2019 06:36, Kushal Gautam wrote:
> Hi JB:
>
> Thank you for your reply.
>
> I tried the options I could.
>
> For example, some suggested that this problem was resolved by using
> Fragment-Host in maven-bundle-plugin as shown
> here: https://github.com/FlavioF/fabric8-osgi-flyway-example/blob/master/fabric8-osgi-flyway/pom.xml
>
> But, doing that, my bundle never started because it gives me another
> error saying: " ... cannot start the fragment host .... "
>
> I am totally clueless.
>
> Regards,
> Cooshal.
>
> On Thu, Aug 1, 2019 at 6:23 AM Jean-Baptiste Onofré <jb@nanthrax.net
> <ma...@nanthrax.net>> wrote:
>
> Hi,
>
> NoClassDefFoundError is certainly due to a class (or several classes) in
> different classloaders.
>
> I don't know Flyway, so I have to take a look how they load the
> providers. It seems an issue in Flyway on OSGi.
>
> Regards
> JB
>
> On 31/07/2019 22:45, Kushal Gautam wrote:
> > Hi,
> >
> > I am trying to use Flyway in my Karaf instance.
> >
> > I have prepared a demo to reproduce the error that I have
> encountered at
> > https://github.com/cooshal/karaf-flyway.
> >
> > I am using a custom built karaf distribution.
> >
> > I have created two different modules inside db-migrations:
> > 1. flyway provider which has implementations to carry out flyway
> migrations
> > 2. karaf command, which invokes the implementation of flyway provider
> > bundle.
> >
> > I tried following:
> >
> > karaf@root()> dbf:migrate
> > Error executing command: java.lang.NoClassDefFoundError: Could not
> > initialize class org.flywaydb.core.Flyway
> >
> > karaf@root()> log:tail
> > 22:37:11.081 ERROR [Karaf local console user karaf] Exception caught
> > while executing command
> > java.util.concurrent.ExecutionException:
> java.lang.NoClassDefFoundError:
> > Could not initialize class org.flywaydb.core.Flyway
> > at java.util.concurrent.FutureTask.report(FutureTask.java:122)
> > ~[?:?]
> > at
> java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:?]
> > at
> >
> org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:829)
> > ~[?:?]
> > at
> >
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> > ~[?:?]
> > 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.lang.NoClassDefFoundError: Could not initialize class
> > org.flywaydb.core.Flyway
> > at
> >
> com.example.db.migrations.FlywayDBMigrations.migrate(FlywayDBMigrations.java:16)
> > ~[?:?]
> > at
> >
> com.example.flyway.command.MigrateDatabaseCommand.execute(MigrateDatabaseCommand.java:20)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
> > ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
> ~[?:?]
> > at
> >
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
> > ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386) ~[?:?]
> > at
> org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) ~[?:?]
> > at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
> ~[?:?]
> > at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
> ~[?:?]
> > ... 4 more
> >
> > I am getting this error from
> >
> https://github.com/cooshal/karaf-flyway/tree/master/db-migrations/flyway-provider
> >
> > I also tried installing flyway-core bundle in Karaf, but it did not
> > work. I got the same error.
> >
> > Do I need to configure some settings in the pom file of this project?
> >
> (https://github.com/cooshal/karaf-flyway/blob/master/db-migrations/flyway-provider/pom.xml)
> >
> > Any feedback would be very helpful.
> >
> > Regards,
> > Cooshal.
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org <ma...@apache.org>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Flyway and Karaf
Posted by Kushal Gautam <ku...@gmail.com>.
Hi again JB:
The problem seemed to have originated from Flyway's classloader, as it
could not load the Logger implementations. Adding a custom LogCreator and
Logger implementations did resolve the issue. (
https://github.com/cooshal/karaf-flyway/tree/master/db-migrations/flyway-provider/src/main/java/com/example/infrastructure).
These custom log implementations were used here (
https://github.com/cooshal/karaf-flyway/blob/master/db-migrations/flyway-provider/src/main/java/com/example/db/migrations/FlywayDBMigrations.java#L19
)
Trying the fix after restarting Karaf did resolve the issue. For those, who
might face this issue in the future, I have a working demo here (
https://github.com/cooshal/karaf-flyway).
Thank you for your help.
Regards,
Cooshal.
On Fri, Aug 2, 2019 at 11:31 AM Kushal Gautam <ku...@gmail.com>
wrote:
> Hi:
>
> I will try that today.
>
> It seems like this is an issue between Flyway and Logging library.
> Although, this error is not very clearly displayed, but I got this error,
> and it was a known issue of flyway and osgi.
>
> I will post back with results.
>
> On Fri, Aug 2, 2019 at 8:17 AM Jean-Baptiste Onofré <jb...@nanthrax.net>
> wrote:
>
>> That's normal, a fragment can be started.
>>
>> By the bay, did you try a simple dynamic import (with the bundle) ?
>>
>> Regards
>> JB
>>
>> On 01/08/2019 09:00, Kushal Gautam wrote:
>> > Hi JB:
>> >
>> > I tried the configuration below, following the example
>> > (
>> https://github.com/FlavioF/fabric8-osgi-flyway-example/blob/master/fabric8-osgi-flyway/pom.xml
>> )
>> >
>> > <plugin>
>> > <groupId>org.apache.felix</groupId>
>> > <artifactId>maven-bundle-plugin</artifactId>
>> > <extensions>true</extensions>
>> > <configuration>
>> > <instructions>
>> > <Fragment-Host>org.flywaydb.core</Fragment-Host>
>> > <Export-Package>
>> > db.migration,
>> > com.example.db.migrations
>> > </Export-Package>
>> > <Import-Package>
>> > org.flywaydb.core.*,
>> > com.example.db.migrations.*,
>> > org.osgi.framework,
>> > com.h2database
>> > </Import-Package>
>> > </instructions>
>> > </configuration>
>> > <executions>
>> > <execution>
>> > <id>bundle-manifest</id>
>> > <phase>process-classes</phase>
>> > <goals>
>> > <goal>manifest</goal>
>> > </goals>
>> > </execution>
>> > </executions>
>> > </plugin>
>> >
>> > But, with this my bundle does not start
>> >
>> > Suppressed: java.lang.Exception: Error starting bundle 85: Fragment
>> > bundles can not be started.
>> > at
>> >
>> org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:67)
>> > ~[?:?]
>> > at
>> >
>> org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:55)
>> > ~[?:?]
>> > at
>> >
>> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>> > ~[?:?]
>> > at
>> >
>> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>> > ~[?:?]
>> > at
>> >
>> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>> > ~[?:?]
>> > at
>> > org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
>> ~[?:?]
>> > at
>> > org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
>> > ~[?:?]
>> > at
>> > org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386) ~[?:?]
>> > at
>> > org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) ~[?:?]
>> > at
>> > org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?]
>> > at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>> > ~[?:?]
>> > 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: org.osgi.framework.BundleException: Fragment bundles
>> > can not be started.
>> > at
>> > org.apache.felix.framework.Felix.startBundle(Felix.java:1986) ~[?:?]
>> > at
>> > org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[?:?]
>> > at
>> > org.apache.karaf.bundle.command.Start.executeOnBundle(Start.java:38)
>> ~[?:?]
>> > at
>> >
>> org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:65)
>> > ~[?:?]
>> > ... 14 more
>> >
>> > What exactly can I do here, to resolve this?
>> >
>> > Thank you.
>> >
>> > Regards,
>> > Cooshal.
>> >
>> > On Thu, Aug 1, 2019 at 6:40 AM Jean-Baptiste Onofré <jb@nanthrax.net
>> > <ma...@nanthrax.net>> wrote:
>> >
>> > Yes, it's what I meant: you have to "gather" the classloaders.
>> >
>> > An option to add all flyway bundles as require bundle/private
>> package in
>> > your own bundle. Like this, all will be in your bundle classloader.
>> >
>> > Another option is to use fragment with your bundle as host (as a
>> > fragment is just resolved, only the host is started).
>> >
>> > Regards
>> > JB
>> >
>> > On 01/08/2019 06:36, Kushal Gautam wrote:
>> > > Hi JB:
>> > >
>> > > Thank you for your reply.
>> > >
>> > > I tried the options I could.
>> > >
>> > > For example, some suggested that this problem was resolved by
>> using
>> > > Fragment-Host in maven-bundle-plugin as shown
>> > >
>> > here:
>> https://github.com/FlavioF/fabric8-osgi-flyway-example/blob/master/fabric8-osgi-flyway/pom.xml
>> > >
>> > > But, doing that, my bundle never started because it gives me
>> another
>> > > error saying: " ... cannot start the fragment host .... "
>> > >
>> > > I am totally clueless.
>> > >
>> > > Regards,
>> > > Cooshal.
>> > >
>> > > On Thu, Aug 1, 2019 at 6:23 AM Jean-Baptiste Onofré
>> > <jb@nanthrax.net <ma...@nanthrax.net>
>> > > <mailto:jb@nanthrax.net <ma...@nanthrax.net>>> wrote:
>> > >
>> > > Hi,
>> > >
>> > > NoClassDefFoundError is certainly due to a class (or several
>> > classes) in
>> > > different classloaders.
>> > >
>> > > I don't know Flyway, so I have to take a look how they load
>> the
>> > > providers. It seems an issue in Flyway on OSGi.
>> > >
>> > > Regards
>> > > JB
>> > >
>> > > On 31/07/2019 22:45, Kushal Gautam wrote:
>> > > > Hi,
>> > > >
>> > > > I am trying to use Flyway in my Karaf instance.
>> > > >
>> > > > I have prepared a demo to reproduce the error that I have
>> > > encountered at
>> > > > https://github.com/cooshal/karaf-flyway.
>> > > >
>> > > > I am using a custom built karaf distribution.
>> > > >
>> > > > I have created two different modules inside db-migrations:
>> > > > 1. flyway provider which has implementations to carry out
>> flyway
>> > > migrations
>> > > > 2. karaf command, which invokes the implementation of flyway
>> > provider
>> > > > bundle.
>> > > >
>> > > > I tried following:
>> > > >
>> > > > karaf@root()> dbf:migrate
>> > > > Error executing command: java.lang.NoClassDefFoundError:
>> > Could not
>> > > > initialize class org.flywaydb.core.Flyway
>> > > >
>> > > > karaf@root()> log:tail
>> > > > 22:37:11.081 ERROR [Karaf local console user karaf]
>> > Exception caught
>> > > > while executing command
>> > > > java.util.concurrent.ExecutionException:
>> > > java.lang.NoClassDefFoundError:
>> > > > Could not initialize class org.flywaydb.core.Flyway
>> > > > at
>> > java.util.concurrent.FutureTask.report(FutureTask.java:122)
>> > > > ~[?:?]
>> > > > at
>> > > java.util.concurrent.FutureTask.get(FutureTask.java:192)
>> ~[?:?]
>> > > > at
>> > > >
>> > >
>> >
>> org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:829)
>> > > > ~[?:?]
>> > > > at
>> > > >
>> > >
>> >
>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>> > > > ~[?:?]
>> > > > 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.lang.NoClassDefFoundError: Could not
>> > initialize class
>> > > > org.flywaydb.core.Flyway
>> > > > at
>> > > >
>> > >
>> >
>> com.example.db.migrations.FlywayDBMigrations.migrate(FlywayDBMigrations.java:16)
>> > > > ~[?:?]
>> > > > at
>> > > >
>> > >
>> >
>> com.example.flyway.command.MigrateDatabaseCommand.execute(MigrateDatabaseCommand.java:20)
>> > > > ~[?:?]
>> > > > at
>> > > >
>> > >
>> >
>> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>> > > > ~[?:?]
>> > > > at
>> > > >
>> > >
>> >
>> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>> > > > ~[?:?]
>> > > > at
>> > > >
>> > >
>> >
>> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>> > > > ~[?:?]
>> > > > at
>> > > >
>> > org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
>> > > ~[?:?]
>> > > > at
>> > > >
>> > >
>> >
>> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
>> > > > ~[?:?]
>> > > > at
>> > > >
>> > org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
>> ~[?:?]
>> > > > at
>> > > org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
>> ~[?:?]
>> > > > at
>> > org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>> > > ~[?:?]
>> > > > at
>> org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>> > > ~[?:?]
>> > > > ... 4 more
>> > > >
>> > > > I am getting this error from
>> > > >
>> > >
>> >
>> https://github.com/cooshal/karaf-flyway/tree/master/db-migrations/flyway-provider
>> > > >
>> > > > I also tried installing flyway-core bundle in Karaf, but it
>> > did not
>> > > > work. I got the same error.
>> > > >
>> > > > Do I need to configure some settings in the pom file of this
>> > project?
>> > > >
>> > >
>> > (
>> https://github.com/cooshal/karaf-flyway/blob/master/db-migrations/flyway-provider/pom.xml
>> )
>> > > >
>> > > > Any feedback would be very helpful.
>> > > >
>> > > > Regards,
>> > > > Cooshal.
>> > >
>> > > --
>> > > Jean-Baptiste Onofré
>> > > jbonofre@apache.org <ma...@apache.org>
>> > <mailto:jbonofre@apache.org <ma...@apache.org>>
>> > > http://blog.nanthrax.net
>> > > Talend - http://www.talend.com
>> > >
>> >
>> > --
>> > Jean-Baptiste Onofré
>> > jbonofre@apache.org <ma...@apache.org>
>> > http://blog.nanthrax.net
>> > Talend - http://www.talend.com
>> >
>>
>> --
>> Jean-Baptiste Onofré
>> jbonofre@apache.org
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
>>
>
Re: Flyway and Karaf
Posted by Kushal Gautam <ku...@gmail.com>.
Hi:
I will try that today.
It seems like this is an issue between Flyway and Logging library.
Although, this error is not very clearly displayed, but I got this error,
and it was a known issue of flyway and osgi.
I will post back with results.
On Fri, Aug 2, 2019 at 8:17 AM Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
> That's normal, a fragment can be started.
>
> By the bay, did you try a simple dynamic import (with the bundle) ?
>
> Regards
> JB
>
> On 01/08/2019 09:00, Kushal Gautam wrote:
> > Hi JB:
> >
> > I tried the configuration below, following the example
> > (
> https://github.com/FlavioF/fabric8-osgi-flyway-example/blob/master/fabric8-osgi-flyway/pom.xml
> )
> >
> > <plugin>
> > <groupId>org.apache.felix</groupId>
> > <artifactId>maven-bundle-plugin</artifactId>
> > <extensions>true</extensions>
> > <configuration>
> > <instructions>
> > <Fragment-Host>org.flywaydb.core</Fragment-Host>
> > <Export-Package>
> > db.migration,
> > com.example.db.migrations
> > </Export-Package>
> > <Import-Package>
> > org.flywaydb.core.*,
> > com.example.db.migrations.*,
> > org.osgi.framework,
> > com.h2database
> > </Import-Package>
> > </instructions>
> > </configuration>
> > <executions>
> > <execution>
> > <id>bundle-manifest</id>
> > <phase>process-classes</phase>
> > <goals>
> > <goal>manifest</goal>
> > </goals>
> > </execution>
> > </executions>
> > </plugin>
> >
> > But, with this my bundle does not start
> >
> > Suppressed: java.lang.Exception: Error starting bundle 85: Fragment
> > bundles can not be started.
> > at
> >
> org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:67)
> > ~[?:?]
> > at
> >
> org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:55)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
> > ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571) ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
> > ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386) ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?]
> > at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
> > ~[?:?]
> > 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: org.osgi.framework.BundleException: Fragment bundles
> > can not be started.
> > at
> > org.apache.felix.framework.Felix.startBundle(Felix.java:1986) ~[?:?]
> > at
> > org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[?:?]
> > at
> > org.apache.karaf.bundle.command.Start.executeOnBundle(Start.java:38)
> ~[?:?]
> > at
> >
> org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:65)
> > ~[?:?]
> > ... 14 more
> >
> > What exactly can I do here, to resolve this?
> >
> > Thank you.
> >
> > Regards,
> > Cooshal.
> >
> > On Thu, Aug 1, 2019 at 6:40 AM Jean-Baptiste Onofré <jb@nanthrax.net
> > <ma...@nanthrax.net>> wrote:
> >
> > Yes, it's what I meant: you have to "gather" the classloaders.
> >
> > An option to add all flyway bundles as require bundle/private
> package in
> > your own bundle. Like this, all will be in your bundle classloader.
> >
> > Another option is to use fragment with your bundle as host (as a
> > fragment is just resolved, only the host is started).
> >
> > Regards
> > JB
> >
> > On 01/08/2019 06:36, Kushal Gautam wrote:
> > > Hi JB:
> > >
> > > Thank you for your reply.
> > >
> > > I tried the options I could.
> > >
> > > For example, some suggested that this problem was resolved by using
> > > Fragment-Host in maven-bundle-plugin as shown
> > >
> > here:
> https://github.com/FlavioF/fabric8-osgi-flyway-example/blob/master/fabric8-osgi-flyway/pom.xml
> > >
> > > But, doing that, my bundle never started because it gives me
> another
> > > error saying: " ... cannot start the fragment host .... "
> > >
> > > I am totally clueless.
> > >
> > > Regards,
> > > Cooshal.
> > >
> > > On Thu, Aug 1, 2019 at 6:23 AM Jean-Baptiste Onofré
> > <jb@nanthrax.net <ma...@nanthrax.net>
> > > <mailto:jb@nanthrax.net <ma...@nanthrax.net>>> wrote:
> > >
> > > Hi,
> > >
> > > NoClassDefFoundError is certainly due to a class (or several
> > classes) in
> > > different classloaders.
> > >
> > > I don't know Flyway, so I have to take a look how they load the
> > > providers. It seems an issue in Flyway on OSGi.
> > >
> > > Regards
> > > JB
> > >
> > > On 31/07/2019 22:45, Kushal Gautam wrote:
> > > > Hi,
> > > >
> > > > I am trying to use Flyway in my Karaf instance.
> > > >
> > > > I have prepared a demo to reproduce the error that I have
> > > encountered at
> > > > https://github.com/cooshal/karaf-flyway.
> > > >
> > > > I am using a custom built karaf distribution.
> > > >
> > > > I have created two different modules inside db-migrations:
> > > > 1. flyway provider which has implementations to carry out
> flyway
> > > migrations
> > > > 2. karaf command, which invokes the implementation of flyway
> > provider
> > > > bundle.
> > > >
> > > > I tried following:
> > > >
> > > > karaf@root()> dbf:migrate
> > > > Error executing command: java.lang.NoClassDefFoundError:
> > Could not
> > > > initialize class org.flywaydb.core.Flyway
> > > >
> > > > karaf@root()> log:tail
> > > > 22:37:11.081 ERROR [Karaf local console user karaf]
> > Exception caught
> > > > while executing command
> > > > java.util.concurrent.ExecutionException:
> > > java.lang.NoClassDefFoundError:
> > > > Could not initialize class org.flywaydb.core.Flyway
> > > > at
> > java.util.concurrent.FutureTask.report(FutureTask.java:122)
> > > > ~[?:?]
> > > > at
> > > java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:?]
> > > > at
> > > >
> > >
> >
> org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:829)
> > > > ~[?:?]
> > > > at
> > > >
> > >
> >
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> > > > ~[?:?]
> > > > 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.lang.NoClassDefFoundError: Could not
> > initialize class
> > > > org.flywaydb.core.Flyway
> > > > at
> > > >
> > >
> >
> com.example.db.migrations.FlywayDBMigrations.migrate(FlywayDBMigrations.java:16)
> > > > ~[?:?]
> > > > at
> > > >
> > >
> >
> com.example.flyway.command.MigrateDatabaseCommand.execute(MigrateDatabaseCommand.java:20)
> > > > ~[?:?]
> > > > at
> > > >
> > >
> >
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
> > > > ~[?:?]
> > > > at
> > > >
> > >
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
> > > > ~[?:?]
> > > > at
> > > >
> > >
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
> > > > ~[?:?]
> > > > at
> > > >
> > org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
> > > ~[?:?]
> > > > at
> > > >
> > >
> >
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
> > > > ~[?:?]
> > > > at
> > > >
> > org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
> ~[?:?]
> > > > at
> > > org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) ~[?:?]
> > > > at
> > org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
> > > ~[?:?]
> > > > at
> org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
> > > ~[?:?]
> > > > ... 4 more
> > > >
> > > > I am getting this error from
> > > >
> > >
> >
> https://github.com/cooshal/karaf-flyway/tree/master/db-migrations/flyway-provider
> > > >
> > > > I also tried installing flyway-core bundle in Karaf, but it
> > did not
> > > > work. I got the same error.
> > > >
> > > > Do I need to configure some settings in the pom file of this
> > project?
> > > >
> > >
> > (
> https://github.com/cooshal/karaf-flyway/blob/master/db-migrations/flyway-provider/pom.xml
> )
> > > >
> > > > Any feedback would be very helpful.
> > > >
> > > > Regards,
> > > > Cooshal.
> > >
> > > --
> > > Jean-Baptiste Onofré
> > > jbonofre@apache.org <ma...@apache.org>
> > <mailto:jbonofre@apache.org <ma...@apache.org>>
> > > http://blog.nanthrax.net
> > > Talend - http://www.talend.com
> > >
> >
> > --
> > Jean-Baptiste Onofré
> > jbonofre@apache.org <ma...@apache.org>
> > http://blog.nanthrax.net
> > Talend - http://www.talend.com
> >
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
Re: Flyway and Karaf
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
That's normal, a fragment can be started.
By the bay, did you try a simple dynamic import (with the bundle) ?
Regards
JB
On 01/08/2019 09:00, Kushal Gautam wrote:
> Hi JB:
>
> I tried the configuration below, following the example
> (https://github.com/FlavioF/fabric8-osgi-flyway-example/blob/master/fabric8-osgi-flyway/pom.xml)
>
> <plugin>
> <groupId>org.apache.felix</groupId>
> <artifactId>maven-bundle-plugin</artifactId>
> <extensions>true</extensions>
> <configuration>
> <instructions>
> <Fragment-Host>org.flywaydb.core</Fragment-Host>
> <Export-Package>
> db.migration,
> com.example.db.migrations
> </Export-Package>
> <Import-Package>
> org.flywaydb.core.*,
> com.example.db.migrations.*,
> org.osgi.framework,
> com.h2database
> </Import-Package>
> </instructions>
> </configuration>
> <executions>
> <execution>
> <id>bundle-manifest</id>
> <phase>process-classes</phase>
> <goals>
> <goal>manifest</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
>
> But, with this my bundle does not start
>
> Suppressed: java.lang.Exception: Error starting bundle 85: Fragment
> bundles can not be started.
> at
> org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:67)
> ~[?:?]
> at
> org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:55)
> ~[?:?]
> at
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
> ~[?:?]
> at
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
> ~[?:?]
> at
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
> ~[?:?]
> at
> org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571) ~[?:?]
> at
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
> ~[?:?]
> at
> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386) ~[?:?]
> at
> org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) ~[?:?]
> at
> org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?]
> at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
> ~[?:?]
> 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: org.osgi.framework.BundleException: Fragment bundles
> can not be started.
> at
> org.apache.felix.framework.Felix.startBundle(Felix.java:1986) ~[?:?]
> at
> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[?:?]
> at
> org.apache.karaf.bundle.command.Start.executeOnBundle(Start.java:38) ~[?:?]
> at
> org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:65)
> ~[?:?]
> ... 14 more
>
> What exactly can I do here, to resolve this?
>
> Thank you.
>
> Regards,
> Cooshal.
>
> On Thu, Aug 1, 2019 at 6:40 AM Jean-Baptiste Onofré <jb@nanthrax.net
> <ma...@nanthrax.net>> wrote:
>
> Yes, it's what I meant: you have to "gather" the classloaders.
>
> An option to add all flyway bundles as require bundle/private package in
> your own bundle. Like this, all will be in your bundle classloader.
>
> Another option is to use fragment with your bundle as host (as a
> fragment is just resolved, only the host is started).
>
> Regards
> JB
>
> On 01/08/2019 06:36, Kushal Gautam wrote:
> > Hi JB:
> >
> > Thank you for your reply.
> >
> > I tried the options I could.
> >
> > For example, some suggested that this problem was resolved by using
> > Fragment-Host in maven-bundle-plugin as shown
> >
> here: https://github.com/FlavioF/fabric8-osgi-flyway-example/blob/master/fabric8-osgi-flyway/pom.xml
> >
> > But, doing that, my bundle never started because it gives me another
> > error saying: " ... cannot start the fragment host .... "
> >
> > I am totally clueless.
> >
> > Regards,
> > Cooshal.
> >
> > On Thu, Aug 1, 2019 at 6:23 AM Jean-Baptiste Onofré
> <jb@nanthrax.net <ma...@nanthrax.net>
> > <mailto:jb@nanthrax.net <ma...@nanthrax.net>>> wrote:
> >
> > Hi,
> >
> > NoClassDefFoundError is certainly due to a class (or several
> classes) in
> > different classloaders.
> >
> > I don't know Flyway, so I have to take a look how they load the
> > providers. It seems an issue in Flyway on OSGi.
> >
> > Regards
> > JB
> >
> > On 31/07/2019 22:45, Kushal Gautam wrote:
> > > Hi,
> > >
> > > I am trying to use Flyway in my Karaf instance.
> > >
> > > I have prepared a demo to reproduce the error that I have
> > encountered at
> > > https://github.com/cooshal/karaf-flyway.
> > >
> > > I am using a custom built karaf distribution.
> > >
> > > I have created two different modules inside db-migrations:
> > > 1. flyway provider which has implementations to carry out flyway
> > migrations
> > > 2. karaf command, which invokes the implementation of flyway
> provider
> > > bundle.
> > >
> > > I tried following:
> > >
> > > karaf@root()> dbf:migrate
> > > Error executing command: java.lang.NoClassDefFoundError:
> Could not
> > > initialize class org.flywaydb.core.Flyway
> > >
> > > karaf@root()> log:tail
> > > 22:37:11.081 ERROR [Karaf local console user karaf]
> Exception caught
> > > while executing command
> > > java.util.concurrent.ExecutionException:
> > java.lang.NoClassDefFoundError:
> > > Could not initialize class org.flywaydb.core.Flyway
> > > at
> java.util.concurrent.FutureTask.report(FutureTask.java:122)
> > > ~[?:?]
> > > at
> > java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:?]
> > > at
> > >
> >
> org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:829)
> > > ~[?:?]
> > > at
> > >
> >
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> > > ~[?:?]
> > > 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.lang.NoClassDefFoundError: Could not
> initialize class
> > > org.flywaydb.core.Flyway
> > > at
> > >
> >
> com.example.db.migrations.FlywayDBMigrations.migrate(FlywayDBMigrations.java:16)
> > > ~[?:?]
> > > at
> > >
> >
> com.example.flyway.command.MigrateDatabaseCommand.execute(MigrateDatabaseCommand.java:20)
> > > ~[?:?]
> > > at
> > >
> >
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
> > > ~[?:?]
> > > at
> > >
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
> > > ~[?:?]
> > > at
> > >
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
> > > ~[?:?]
> > > at
> > >
> org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
> > ~[?:?]
> > > at
> > >
> >
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
> > > ~[?:?]
> > > at
> > >
> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386) ~[?:?]
> > > at
> > org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) ~[?:?]
> > > at
> org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
> > ~[?:?]
> > > at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
> > ~[?:?]
> > > ... 4 more
> > >
> > > I am getting this error from
> > >
> >
> https://github.com/cooshal/karaf-flyway/tree/master/db-migrations/flyway-provider
> > >
> > > I also tried installing flyway-core bundle in Karaf, but it
> did not
> > > work. I got the same error.
> > >
> > > Do I need to configure some settings in the pom file of this
> project?
> > >
> >
> (https://github.com/cooshal/karaf-flyway/blob/master/db-migrations/flyway-provider/pom.xml)
> > >
> > > Any feedback would be very helpful.
> > >
> > > Regards,
> > > Cooshal.
> >
> > --
> > Jean-Baptiste Onofré
> > jbonofre@apache.org <ma...@apache.org>
> <mailto:jbonofre@apache.org <ma...@apache.org>>
> > http://blog.nanthrax.net
> > Talend - http://www.talend.com
> >
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org <ma...@apache.org>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Flyway and Karaf
Posted by Kushal Gautam <ku...@gmail.com>.
Hi JB:
I tried the configuration below, following the example (
https://github.com/FlavioF/fabric8-osgi-flyway-example/blob/master/fabric8-osgi-flyway/pom.xml
)
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Fragment-Host>org.flywaydb.core</Fragment-Host>
<Export-Package>
db.migration,
com.example.db.migrations
</Export-Package>
<Import-Package>
org.flywaydb.core.*,
com.example.db.migrations.*,
org.osgi.framework,
com.h2database
</Import-Package>
</instructions>
</configuration>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
But, with this my bundle does not start
Suppressed: java.lang.Exception: Error starting bundle 85: Fragment bundles
can not be started.
at
org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:67)
~[?:?]
at
org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:55)
~[?:?]
at
org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
~[?:?]
at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
~[?:?]
at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
~[?:?]
at
org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571) ~[?:?]
at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
~[?:?]
at
org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386) ~[?:?]
at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
~[?:?]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
~[?:?]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
~[?:?]
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: org.osgi.framework.BundleException: Fragment bundles can
not be started.
at
org.apache.felix.framework.Felix.startBundle(Felix.java:1986) ~[?:?]
at
org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[?:?]
at
org.apache.karaf.bundle.command.Start.executeOnBundle(Start.java:38) ~[?:?]
at
org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:65)
~[?:?]
... 14 more
What exactly can I do here, to resolve this?
Thank you.
Regards,
Cooshal.
On Thu, Aug 1, 2019 at 6:40 AM Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
> Yes, it's what I meant: you have to "gather" the classloaders.
>
> An option to add all flyway bundles as require bundle/private package in
> your own bundle. Like this, all will be in your bundle classloader.
>
> Another option is to use fragment with your bundle as host (as a
> fragment is just resolved, only the host is started).
>
> Regards
> JB
>
> On 01/08/2019 06:36, Kushal Gautam wrote:
> > Hi JB:
> >
> > Thank you for your reply.
> >
> > I tried the options I could.
> >
> > For example, some suggested that this problem was resolved by using
> > Fragment-Host in maven-bundle-plugin as shown
> > here:
> https://github.com/FlavioF/fabric8-osgi-flyway-example/blob/master/fabric8-osgi-flyway/pom.xml
> >
> > But, doing that, my bundle never started because it gives me another
> > error saying: " ... cannot start the fragment host .... "
> >
> > I am totally clueless.
> >
> > Regards,
> > Cooshal.
> >
> > On Thu, Aug 1, 2019 at 6:23 AM Jean-Baptiste Onofré <jb@nanthrax.net
> > <ma...@nanthrax.net>> wrote:
> >
> > Hi,
> >
> > NoClassDefFoundError is certainly due to a class (or several
> classes) in
> > different classloaders.
> >
> > I don't know Flyway, so I have to take a look how they load the
> > providers. It seems an issue in Flyway on OSGi.
> >
> > Regards
> > JB
> >
> > On 31/07/2019 22:45, Kushal Gautam wrote:
> > > Hi,
> > >
> > > I am trying to use Flyway in my Karaf instance.
> > >
> > > I have prepared a demo to reproduce the error that I have
> > encountered at
> > > https://github.com/cooshal/karaf-flyway.
> > >
> > > I am using a custom built karaf distribution.
> > >
> > > I have created two different modules inside db-migrations:
> > > 1. flyway provider which has implementations to carry out flyway
> > migrations
> > > 2. karaf command, which invokes the implementation of flyway
> provider
> > > bundle.
> > >
> > > I tried following:
> > >
> > > karaf@root()> dbf:migrate
> > > Error executing command: java.lang.NoClassDefFoundError: Could not
> > > initialize class org.flywaydb.core.Flyway
> > >
> > > karaf@root()> log:tail
> > > 22:37:11.081 ERROR [Karaf local console user karaf] Exception
> caught
> > > while executing command
> > > java.util.concurrent.ExecutionException:
> > java.lang.NoClassDefFoundError:
> > > Could not initialize class org.flywaydb.core.Flyway
> > > at
> java.util.concurrent.FutureTask.report(FutureTask.java:122)
> > > ~[?:?]
> > > at
> > java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:?]
> > > at
> > >
> >
> org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:829)
> > > ~[?:?]
> > > at
> > >
> >
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> > > ~[?:?]
> > > 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.lang.NoClassDefFoundError: Could not initialize
> class
> > > org.flywaydb.core.Flyway
> > > at
> > >
> >
> com.example.db.migrations.FlywayDBMigrations.migrate(FlywayDBMigrations.java:16)
> > > ~[?:?]
> > > at
> > >
> >
> com.example.flyway.command.MigrateDatabaseCommand.execute(MigrateDatabaseCommand.java:20)
> > > ~[?:?]
> > > at
> > >
> >
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
> > > ~[?:?]
> > > at
> > >
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
> > > ~[?:?]
> > > at
> > >
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
> > > ~[?:?]
> > > at
> > > org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
> > ~[?:?]
> > > at
> > >
> >
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
> > > ~[?:?]
> > > at
> > > org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
> ~[?:?]
> > > at
> > org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) ~[?:?]
> > > at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
> > ~[?:?]
> > > at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
> > ~[?:?]
> > > ... 4 more
> > >
> > > I am getting this error from
> > >
> >
> https://github.com/cooshal/karaf-flyway/tree/master/db-migrations/flyway-provider
> > >
> > > I also tried installing flyway-core bundle in Karaf, but it did not
> > > work. I got the same error.
> > >
> > > Do I need to configure some settings in the pom file of this
> project?
> > >
> > (
> https://github.com/cooshal/karaf-flyway/blob/master/db-migrations/flyway-provider/pom.xml
> )
> > >
> > > Any feedback would be very helpful.
> > >
> > > Regards,
> > > Cooshal.
> >
> > --
> > Jean-Baptiste Onofré
> > jbonofre@apache.org <ma...@apache.org>
> > http://blog.nanthrax.net
> > Talend - http://www.talend.com
> >
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
Re: Flyway and Karaf
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Yes, it's what I meant: you have to "gather" the classloaders.
An option to add all flyway bundles as require bundle/private package in
your own bundle. Like this, all will be in your bundle classloader.
Another option is to use fragment with your bundle as host (as a
fragment is just resolved, only the host is started).
Regards
JB
On 01/08/2019 06:36, Kushal Gautam wrote:
> Hi JB:
>
> Thank you for your reply.
>
> I tried the options I could.
>
> For example, some suggested that this problem was resolved by using
> Fragment-Host in maven-bundle-plugin as shown
> here: https://github.com/FlavioF/fabric8-osgi-flyway-example/blob/master/fabric8-osgi-flyway/pom.xml
>
> But, doing that, my bundle never started because it gives me another
> error saying: " ... cannot start the fragment host .... "
>
> I am totally clueless.
>
> Regards,
> Cooshal.
>
> On Thu, Aug 1, 2019 at 6:23 AM Jean-Baptiste Onofré <jb@nanthrax.net
> <ma...@nanthrax.net>> wrote:
>
> Hi,
>
> NoClassDefFoundError is certainly due to a class (or several classes) in
> different classloaders.
>
> I don't know Flyway, so I have to take a look how they load the
> providers. It seems an issue in Flyway on OSGi.
>
> Regards
> JB
>
> On 31/07/2019 22:45, Kushal Gautam wrote:
> > Hi,
> >
> > I am trying to use Flyway in my Karaf instance.
> >
> > I have prepared a demo to reproduce the error that I have
> encountered at
> > https://github.com/cooshal/karaf-flyway.
> >
> > I am using a custom built karaf distribution.
> >
> > I have created two different modules inside db-migrations:
> > 1. flyway provider which has implementations to carry out flyway
> migrations
> > 2. karaf command, which invokes the implementation of flyway provider
> > bundle.
> >
> > I tried following:
> >
> > karaf@root()> dbf:migrate
> > Error executing command: java.lang.NoClassDefFoundError: Could not
> > initialize class org.flywaydb.core.Flyway
> >
> > karaf@root()> log:tail
> > 22:37:11.081 ERROR [Karaf local console user karaf] Exception caught
> > while executing command
> > java.util.concurrent.ExecutionException:
> java.lang.NoClassDefFoundError:
> > Could not initialize class org.flywaydb.core.Flyway
> > at java.util.concurrent.FutureTask.report(FutureTask.java:122)
> > ~[?:?]
> > at
> java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:?]
> > at
> >
> org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:829)
> > ~[?:?]
> > at
> >
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> > ~[?:?]
> > 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.lang.NoClassDefFoundError: Could not initialize class
> > org.flywaydb.core.Flyway
> > at
> >
> com.example.db.migrations.FlywayDBMigrations.migrate(FlywayDBMigrations.java:16)
> > ~[?:?]
> > at
> >
> com.example.flyway.command.MigrateDatabaseCommand.execute(MigrateDatabaseCommand.java:20)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
> > ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
> ~[?:?]
> > at
> >
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
> > ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386) ~[?:?]
> > at
> org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) ~[?:?]
> > at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
> ~[?:?]
> > at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
> ~[?:?]
> > ... 4 more
> >
> > I am getting this error from
> >
> https://github.com/cooshal/karaf-flyway/tree/master/db-migrations/flyway-provider
> >
> > I also tried installing flyway-core bundle in Karaf, but it did not
> > work. I got the same error.
> >
> > Do I need to configure some settings in the pom file of this project?
> >
> (https://github.com/cooshal/karaf-flyway/blob/master/db-migrations/flyway-provider/pom.xml)
> >
> > Any feedback would be very helpful.
> >
> > Regards,
> > Cooshal.
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org <ma...@apache.org>
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Flyway and Karaf
Posted by Kushal Gautam <ku...@gmail.com>.
Hi JB:
Thank you for your reply.
I tried the options I could.
For example, some suggested that this problem was resolved by using
Fragment-Host in maven-bundle-plugin as shown here:
https://github.com/FlavioF/fabric8-osgi-flyway-example/blob/master/fabric8-osgi-flyway/pom.xml
But, doing that, my bundle never started because it gives me another error
saying: " ... cannot start the fragment host .... "
I am totally clueless.
Regards,
Cooshal.
On Thu, Aug 1, 2019 at 6:23 AM Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
> Hi,
>
> NoClassDefFoundError is certainly due to a class (or several classes) in
> different classloaders.
>
> I don't know Flyway, so I have to take a look how they load the
> providers. It seems an issue in Flyway on OSGi.
>
> Regards
> JB
>
> On 31/07/2019 22:45, Kushal Gautam wrote:
> > Hi,
> >
> > I am trying to use Flyway in my Karaf instance.
> >
> > I have prepared a demo to reproduce the error that I have encountered at
> > https://github.com/cooshal/karaf-flyway.
> >
> > I am using a custom built karaf distribution.
> >
> > I have created two different modules inside db-migrations:
> > 1. flyway provider which has implementations to carry out flyway
> migrations
> > 2. karaf command, which invokes the implementation of flyway provider
> > bundle.
> >
> > I tried following:
> >
> > karaf@root()> dbf:migrate
> > Error executing command: java.lang.NoClassDefFoundError: Could not
> > initialize class org.flywaydb.core.Flyway
> >
> > karaf@root()> log:tail
> > 22:37:11.081 ERROR [Karaf local console user karaf] Exception caught
> > while executing command
> > java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError:
> > Could not initialize class org.flywaydb.core.Flyway
> > at java.util.concurrent.FutureTask.report(FutureTask.java:122)
> > ~[?:?]
> > at java.util.concurrent.FutureTask.get(FutureTask.java:192)
> ~[?:?]
> > at
> >
> org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:829)
> > ~[?:?]
> > at
> > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> > ~[?:?]
> > 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.lang.NoClassDefFoundError: Could not initialize class
> > org.flywaydb.core.Flyway
> > at
> >
> com.example.db.migrations.FlywayDBMigrations.migrate(FlywayDBMigrations.java:16)
> > ~[?:?]
> > at
> >
> com.example.flyway.command.MigrateDatabaseCommand.execute(MigrateDatabaseCommand.java:20)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
> > ~[?:?]
> > at
> >
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
> > ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571) ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
> > ~[?:?]
> > at
> > org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386) ~[?:?]
> > at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
> ~[?:?]
> > at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?]
> > at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) ~[?:?]
> > ... 4 more
> >
> > I am getting this error from
> >
> https://github.com/cooshal/karaf-flyway/tree/master/db-migrations/flyway-provider
> >
> > I also tried installing flyway-core bundle in Karaf, but it did not
> > work. I got the same error.
> >
> > Do I need to configure some settings in the pom file of this project?
> > (
> https://github.com/cooshal/karaf-flyway/blob/master/db-migrations/flyway-provider/pom.xml
> )
> >
> > Any feedback would be very helpful.
> >
> > Regards,
> > Cooshal.
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>
Re: Flyway and Karaf
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,
NoClassDefFoundError is certainly due to a class (or several classes) in
different classloaders.
I don't know Flyway, so I have to take a look how they load the
providers. It seems an issue in Flyway on OSGi.
Regards
JB
On 31/07/2019 22:45, Kushal Gautam wrote:
> Hi,
>
> I am trying to use Flyway in my Karaf instance.
>
> I have prepared a demo to reproduce the error that I have encountered at
> https://github.com/cooshal/karaf-flyway.
>
> I am using a custom built karaf distribution.
>
> I have created two different modules inside db-migrations:
> 1. flyway provider which has implementations to carry out flyway migrations
> 2. karaf command, which invokes the implementation of flyway provider
> bundle.
>
> I tried following:
>
> karaf@root()> dbf:migrate
> Error executing command: java.lang.NoClassDefFoundError: Could not
> initialize class org.flywaydb.core.Flyway
>
> karaf@root()> log:tail
> 22:37:11.081 ERROR [Karaf local console user karaf] Exception caught
> while executing command
> java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError:
> Could not initialize class org.flywaydb.core.Flyway
> at java.util.concurrent.FutureTask.report(FutureTask.java:122)
> ~[?:?]
> at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:?]
> at
> org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:829)
> ~[?:?]
> at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> ~[?:?]
> 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.lang.NoClassDefFoundError: Could not initialize class
> org.flywaydb.core.Flyway
> at
> com.example.db.migrations.FlywayDBMigrations.migrate(FlywayDBMigrations.java:16)
> ~[?:?]
> at
> com.example.flyway.command.MigrateDatabaseCommand.execute(MigrateDatabaseCommand.java:20)
> ~[?:?]
> at
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
> ~[?:?]
> at
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
> ~[?:?]
> at
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
> ~[?:?]
> at
> org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571) ~[?:?]
> at
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
> ~[?:?]
> at
> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386) ~[?:?]
> at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) ~[?:?]
> at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?]
> at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) ~[?:?]
> ... 4 more
>
> I am getting this error from
> https://github.com/cooshal/karaf-flyway/tree/master/db-migrations/flyway-provider
>
> I also tried installing flyway-core bundle in Karaf, but it did not
> work. I got the same error.
>
> Do I need to configure some settings in the pom file of this project?
> (https://github.com/cooshal/karaf-flyway/blob/master/db-migrations/flyway-provider/pom.xml)
>
> Any feedback would be very helpful.
>
> Regards,
> Cooshal.
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com