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é <j...@nanthrax.net > <mailto:j...@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é > jbono...@apache.org <mailto:jbono...@apache.org> > http://blog.nanthrax.net > Talend - http://www.talend.com > -- Jean-Baptiste Onofré jbono...@apache.org http://blog.nanthrax.net Talend - http://www.talend.com