Thanks. Unfortunately this also raises the InterruptedException. After digging deeper it seems this is caused by the aQute.launcher.Launcher which is wrapped around the Framework in BndTools (should have seen that from the stacktrace in the beginning).
So I guess I have to live with that exception. - Marc Von: Raymond Auge <raymond.a...@liferay.com> An: felix users <users@felix.apache.org>, Datum: 17.09.2015 16:25 Betreff: Re: InterruptedException when stopping system-bundle What you probably want is: Framework fw = context.getBundle(0).adapt(Framework.class); fw.waitForStop(timeout); - Ray On Thu, Sep 17, 2015 at 4:02 PM, <marc.schle...@sdv-it.de> wrote: > Hello everyone > > I created a little executable-jar which launches Felix. After some > computation has been done the framework is shutdown by using > context.getBundle(0).stop() > > This however always throws an InterruptedException > > java.lang.InterruptedException > at java.lang.Object.wait(Native Method) > at > org.apache.felix.framework.util.ThreadGate.await(ThreadGate.java:79) > at org.apache.felix.framework.Felix.waitForStop(Felix.java:1068) > at aQute.launcher.Launcher.deactivate(Launcher.java:738) > at aQute.launcher.Launcher.run(Launcher.java:287) > at aQute.launcher.Launcher.main(Launcher.java:87) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) > at java.lang.reflect.Method.invoke(Unknown Source) > at > aQute.launcher.pre.EmbeddedLauncher.main(EmbeddedLauncher.java:38) > > My only guess is, that this has something to do with the way I execute my > code: I use an @Activate method which runs some code and shuts down the > framework before it completes > > @Activate > void activate(ComponentContext ctx){ > this.context = ctx.getBundleContext(); > try{ > executeGroovy(); > }catch(Throwable t){ > t.printStackTrace(); > } > > String keepAlive = context.getProperty( > "de.sdv.geb.runner.keepAlive"); > > if(!Boolean.parseBoolean(keepAlive)){ > try { > System.out.println("Shutting down"); > context.getBundle(0).stop(); > } catch (BundleException e) { > System.err.println("Error stopping > OSGI-Container...killing VM now"); > e.printStackTrace(); > // hard way > System.exit(1); > } > } > } > > Using Felix 5.2.0 and the executable jar is created with BndTool 3.0.0 > from a run-descriptor. > > Any ideas how to get rid of this exceptions? > > Thanks > Marc -- *Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile> (@rotty3000) Senior Software Architect *Liferay, Inc.* <http://www.liferay.com> (@Liferay) Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org> (@OSGiAlliance)