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é <[email protected] > <mailto:[email protected]>> 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é > <[email protected] <mailto:[email protected]> > > <mailto:[email protected] <mailto:[email protected]>>> 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é > > [email protected] <mailto:[email protected]> > <mailto:[email protected] <mailto:[email protected]>> > > http://blog.nanthrax.net > > Talend - http://www.talend.com > > > > -- > Jean-Baptiste Onofré > [email protected] <mailto:[email protected]> > http://blog.nanthrax.net > Talend - http://www.talend.com > -- Jean-Baptiste Onofré [email protected] http://blog.nanthrax.net Talend - http://www.talend.com
