Hi everyone,
I am not sure if this is the right place to ask this question. Please direct me the right place if this is not.
I am new to Declarative Services (DS) but not new to OSGi. I have been developing desktop applications using Knopflerfish 2 and Gravity Service Binder the last four years. We are looking into moving to the latest OSGi and continue to use Knopflerfish container. I spent the last couple of days creating simple bundles and tried out Knopflerfish 7.0.1 and DS, but I am facing problems that I can't seem to find the answer on Google. Hopefully you guys can help me figure out what I am missing. Do I need to place the description xml file in OSGI-INF or I can put anywhere as long as I reference it to the right location in the manifest file? Anyway, I have tried to put it in OSGI-INF but it doesn't work either.
Here is the problem. My bundles work just fine if I implement Activator class myself. But they don't work if I use DS. When I launch the program it doesn't give me any error. The "ps" command show both of my bundle are active. One of the bundle is supposed to print some text to the screen every second.
Manifest-Version: 2.0
Bundle-Name: simple
Bundle-SymbolicName: Simple Bundle
Bundle-Version: 1.0.0
Bundle-Description: Simple Bundle component
Bundle-Vendor: Some Vendor
Bundle-Category: testing
Import-Package: org.osgi.framework
Service-Component: config/simple.xml
And below is the log:
Knopflerfish OSGi framework launcher, version 7.0.1
Copyright 2003-2013 Knopflerfish. All Rights Reserved.
See http://www.knopflerfish.org for more information.
Created Framework: org.knopflerfish.framework, version=7.0.1.
Framework launched
ps
id level/state name
0 0/active System Bundle 1 1/resolved Log Service-API
2 1/resolved Console-API 3 1/active cm-API
4 1/active Log Service-IMPL 5 1/active Console-IMPL
6 1/active TTY-Console-IMPL 7 1/active Telnet-Console-IMPL
8 1/active FW-Commands-IMPL 9 1/active LogCommands-IMPL
10 1/active UserAdmin-API 11 1/active kXML 2-LIB
12 1/active SCR 13 1/active gui
14 1/active simple
services
Bundle: Console-IMPL (#5)
registered: ConsoleService
Bundle: FW-Commands-IMPL (#8)
registered: CommandGroup
Bundle: Log Service-IMPL (#4)
registered: LogReaderService [ManagedService,LogConfig] [LogService,LogService]
Bundle: LogCommands-IMPL (#9)
registered: CommandGroup CommandGroup
Bundle: SCR (#12)
registered: ScrService ConfigurationListener
Bundle: System Bundle (#0)
registered: PackageAdmin StartLevel
Bundle: TTY-Console-IMPL (#6)
registered: ManagedService
Bundle: Telnet-Console-IMPL (#7)
registered: ManagedService
The component description xml document can go anywhere in the bundle.
You tell the SCR-bundle (called component on the Knopflerfish distribution) where to look for them in the Service-Component header.
E.g. with
Service-Component: config/simple.xml
there should be a file in the bundles jar-archive with the path
/config/simple.xml
The recommendation is to place component descriptions in the OSGI-INF directory to keep meta-data separated form the actual code.
To inspect the state of service components from the KF-console we provide a small bundle (that uses SCR) to publish a console command group. This bundle is available from
http://www.knopflerfish.org/releases/current/osgi/jars/scrcommands/scrcommands-4.0.1.jar
and you will also find it in your downloaded Knopflerfish distribution.
Hi Gunnar,
Thanks for your suggestion about placing component descriptions in OSGI-INF directory. I will keep that in mind.
With your hint I was able to figure out the problems and finally got my bundles to register with the framework using Declarative Services. I want to share my experience so if someone comes across the issue knows what to look for:
Our Ant build.xml script does not include the component description file in the jar (this was done intentionally). From your hint, I looked in the jar and didn't see the xml file. I edit the jar to include the xml file and thing gets better.
But then my simple and gui bundles still didn't do anything even though both showed active. So I issued "scr list" and "scr show" commands and saw UNSATISFIED status. This hint gave me a clue where to look: One of my bundle required other bundle (specified in the component description xml file) that has not yet started. Fixing that bundle resolved the issue.
Do you know of any tools out there that help troubleshooting application issues related to OSGi framework?
Again, thanks for your help.
QV
Closing since this was a usage question and not a bug in Knopflerfish.
Ticket moved from /p/gatespace/bugs/180/