How are you looking up the LogServiceReader ? I would guess you're looking it up in the start method of an Activator.
An important concept in OSGi is to try and not be dependant on the order of bundle activation. What you need to do is use a more robust way of handling the dynamic nature of the services you need, for instance by using Declarative Services (or, a bit more complicated, a ServiceTracker if you don't want to have SCR in your container for some reason). Here's a few related links: www.aqute.biz/Snippets/HelloWorldComponent www.eclipsezone.com/eclipse/forums/t97690.rhtml www.knopflerfish.org/osgi_service_tutorial.html Cheers, Chris On 10 May 2010 08:59, Luis Rodero-Merino <[email protected]> wrote: > Hi, > > I'm testing Felix 2.0.5, and I've found a behaviour that is a bit > strange to me. I have a bundle that depends on the LogServiceReader > service although it is expressed in the Import-Package header. Now, > when I copy the bundle .jar file with log-bundle.jar name and start > felix (no felix-cache/ dir available, all is started from bundle/ dir) > my bundle cannot find that service that is provided by 'Apache Felix > Log Service'. This is the results of the 'ps' command: > > -> ps > START LEVEL 1 > ID State Level Name > [ 0] [Active ] [ 0] System Bundle (2.0.5) > [ 1] [Active ] [ 1] LogWriter (1.0.0) > [ 2] [Active ] [ 1] Apache Felix Bundle Repository (1.4.3) > [ 3] [Active ] [ 1] Apache Felix Log Service (1.0.0) > [ 4] [Active ] [ 1] Apache Felix Shell Service (1.4.2) > [ 5] [Active ] [ 1] Apache Felix Shell TUI (1.4.1) > [ 6] [Active ] [ 1] Test1 (1.0.0) > [ 7] [Active ] [ 1] Test2 (1.0.0) > > And this is the result of the 'headers 1' command (please note that > the Import-Package is properly set): > -> headers 1 > > LogWriter (1) > ------------- > Ant-Version = Apache Ant 1.7.1 > Bundle-Activator = tests.LogWriterActivator > Bundle-Description = Bundle Log that adds a writer of log messages to > default OSGi log service > Bundle-Name = LogWriter > Bundle-Vendor = Luis [email protected] > Bundle-Version = 1.0.0 > Created-By = 14.0-b16 (Sun Microsystems Inc.) > Import-Package = org.osgi.framework,org.osgi.service.log > Manifest-Version = 1.0 > > > Now, if I remove felix-cache/ dir again, and I rename my bundle file > like 'mv bundle/log-bundle.jar bundle/zlog-bundle.jar' we have that > the LogServiceReader is properly found (no error message found, and > the log works just fine). The reason seems that my bundle .jar is > found now after the Apache Felix Log Service bundle .jar. The 'ps' > returns: > > -> ps > START LEVEL 1 > ID State Level Name > [ 0] [Active ] [ 0] System Bundle (2.0.5) > [ 1] [Active ] [ 1] Apache Felix Bundle Repository (1.4.3) > [ 2] [Active ] [ 1] Apache Felix Log Service (1.0.0) > [ 3] [Active ] [ 1] Apache Felix Shell Service (1.4.2) > [ 4] [Active ] [ 1] Apache Felix Shell TUI (1.4.1) > [ 5] [Active ] [ 1] Test1 (1.0.0) > [ 6] [Active ] [ 1] Test2 (1.0.0) > [ 7] [Active ] [ 1] LogWriter (1.0.0) > > (Note that the id of my bundle is now 7 instead of 1). The 'headers 7' > command returns just the same as before: > -> headers 7 > > LogWriter (7) > ------------- > Ant-Version = Apache Ant 1.7.1 > Bundle-Activator = tests.LogWriterActivator > Bundle-Description = Bundle Log that adds a writer of log messages to > default OSGi log service > Bundle-Name = LogWriter > Bundle-Vendor = Luis [email protected] > Bundle-Version = 1.0.0 > Created-By = 14.0-b16 (Sun Microsystems Inc.) > Import-Package = org.osgi.framework,org.osgi.service.log > Manifest-Version = 1.0 > > > Now, it seems to me a bit weird that changing the bundle file name > changes also the resolution results process. Is this the way felix is > supposed to work? Is this according to the spec? > > Best regards and thanks for your help! > > Luis Rodero-Merino > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >

