After reading the javadoc of the OSGi reference implementation ( http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html) I was able to solve my problem by myself:
To remove my application bundle completely I had to use the functionality of the package admin service. Otherwise the bundle remains in the framework as a "zombie bundle". BR, Markus 2009/9/17 Markus Michel <[email protected]> > As you can see from the BundleHandler class I'm currently only comparing > the bundle state with the expected state after starting / stopping a bundle. > This evening I will add such a check to the methods, which install / > uninstall a bundle as well and report the results ... > > 2009/9/17 Karl Pauls <[email protected]> > > On Wed, Sep 16, 2009 at 9:23 PM, Markus Michel >> <[email protected]> wrote: >> > Hi Karl! >> > >> > After catching Throwable and Exception as well my output looks like >> this: >> > >> > trying to stop bundle 7 <- vehicle 1055293 left the scenario => reset of >> > framework 1 >> > bundle 7 was stopped <- reset of application >> > try to uninstall bundle 7 >> > bundle 7 was uninstalled >> > trying to install >> > file:/home/markus/bundles/application/VehicleBeaconingApp_1.0.0.jar >> > file:/home/markus/bundles/application/VehicleBeaconingApp_1.0.0.jar was >> > installed >> > vehicle id 1055293 successfully unbounded from framework 1 >> > trying to start bundle 7 <- new vehicle tries to bind to framework 1 => >> > start of application >> > exception java.lang.IllegalStateException: Cannot start an uninstalled >> > bundle. >> > bundle 7 was started >> > error: bundle 7 is not running >> > >> > Mhhh, the exception doesn't really make sense, because the application >> > (bundle 7) should be in the state INSTALLED, when the vehicle tries to >> start >> > it. Maybe the process of stopping / uninstalling and reinstalled the >> bundles >> > takes internally longer than I exspect from the output?!? >> >> Can you show us what it is you do exactly? It sounds like you are not >> waiting long enough ... how do you make sure the bundle has been >> uninstalled? One way might be to call refresh after uninstall and wait >> for the refreshed event... >> >> regards, >> >> Karl >> >> > BTW: Currently I'm not sure if the new vehicle contacts my framework >> handler >> > using the same thread. So maybe I have to synchronize same parts of my >> code, >> > too ... I will think about that more detailed tomorrow ... >> > >> > BR, >> > >> > Markus >> > >> > 2009/9/16 Karl Pauls <[email protected]> >> > >> >> Can't you catch Throwable as well and give us a stacktrace of whatever >> >> exception/error gets thrown by the start() method? >> >> >> >> regards, >> >> >> >> Karl >> >> >> >> On Wed, Sep 16, 2009 at 3:48 PM, Markus Michel >> >> <[email protected]> wrote: >> >> > Hi there! >> >> > >> >> > Here's a short explanation, how my program is working: >> >> > >> >> > Inside my program I using a FrameworkHandler class to control a pool >> of >> >> OSGi >> >> > instances, which represents vehicles of a traffic simulation, For >> every >> >> > instances I using three BundleHandler ( system, user, application) to >> >> > install / uninstall / start / stop a list of bundles. When the >> program is >> >> > started the pool is initialized and all system (OSGi services, Shell >> ..) >> >> and >> >> > user (my services) bundles are installed and started. Everytime (if >> there >> >> is >> >> > a free instance) there is a new vehicle, my program binds it to an >> >> instance >> >> > of the pool and installs / started an application, which should be >> >> running >> >> > on this vehicle using the application bundle handler. If the vehicles >> >> leaves >> >> > the scenario, the program resets the application by stopping, >> uninstalled >> >> > and reinstalling the corresponding bundles. Afterwards a new vehicle >> can >> >> be >> >> > bound the same instance. >> >> > >> >> > My problem is that currently my program seems to hang into a loop, >> when >> >> the >> >> > application bundle is started after it was reset. By doing some >> printouts >> >> I >> >> > know that the problem occurs into that code block: >> >> > >> >> > // start bundle >> >> > try >> >> > { >> >> > bundle.start(); >> >> > } >> >> > catch (BundleException e) >> >> > { >> >> > System.out.println("error: could not start bundle " + >> >> > bundle.getBundleId()); >> >> > System.out.println(e); >> >> > System.exit(1); >> >> > } >> >> > >> >> > I'm not sure what really happens, because there is no bundle >> exception, >> >> > although the error occurs inside the call of the start method. Isn't >> it >> >> > possible to "reset" an OSGi bundle? >> >> > >> >> > Because I though that my problem might be a bug of the framework i >> >> already >> >> > upgraded my program to the new felix version 2.0.0, but the problem >> still >> >> > appears ... >> >> > >> >> > BR, >> >> > >> >> > Markus >> >> > >> >> >> >> >> >> >> >> -- >> >> Karl Pauls >> >> [email protected] >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: [email protected] >> >> For additional commands, e-mail: [email protected] >> >> >> >> >> > >> >> >> >> -- >> Karl Pauls >> [email protected] >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > > -- > Mit freundlichen Grüßen, > > Markus Michel > -- Mit freundlichen Grüßen, Markus Michel

