/
OSGi Troubleshooting
OSGi Troubleshooting
- Features
- If you depend on other apps, features, or bundles, make sure those are called out explicitly. This will save you a lot of pain troubleshooting missing dependencies later on.
- Bundles
- If your bundle fails to start, read your manifest.
bundle:list | grep -i <your bundle name>
, thenheaders <bundle number>
. Any unresolved imports will be highlighted in red. - Bundle imports must be satisfied by bundle exports somewhere in the container. If you are wiring bundles together, double-check this on both ends. You can also
exports | grep -i <package>
to verify.- The maven-bundle-plugin is not perfect. Sometimes you will need to exclude an undesired transitive dependency, or explicitly import an additional package. You should always be explicit with your exports.
- If you have dependencies that are satisfied by a jar rather than a bundle, you will need to embed those dependencies. Verify you are embedding everything you need.
- If you are still missing something, make sure all your prereqs are started. You may be missing something in your features file if that is the case.
- If your bundle fails to start, read your manifest.
- Blueprint
- Beans
- When instantiating beans, you must use the fully qualified class name.
- If you get a 'cannot cast' error, check your types.
- Bean args do not care about names, only ctor order and type.
- Bean properties expect a corresponding setter, e.g. if your property is named
foobar
, blueprint will look for a matchingsetFoobar
in your class.
- Services
- When exporting services, it's best to explicitly declare interfaces.
- When binding to someone else's service, make sure the providing bundle is active, verify the service is being exported with
services | grep -i <service>
, and double-check the interface of your service ref.
- Beans
- Metatype
- When a bundle comes up, beans will always be populated with any blueprint defaults before they get updated with their metatype properties.
- Check the pid of your metatype and managed-properties.
- Metatype and blueprint property names must match.
- Classloader
- Every bundle gets its own classloader. This means you can't freely share static classes between bundles like you could in a standard java application. Bundles should only communicate using services, which requires an interface for each one.
- Watch out for split packages. If two different bundles have two different packages with the same name and you try to wire them together, this may fail with an
IllegalAccessError
.
, multiple selections available,
Related content
Maven POM file best practices
Maven POM file best practices
More like this
OSGi Security Manager
OSGi Security Manager
More like this
Maven Checklist
Maven Checklist
More like this
Parent POMs
Parent POMs
More like this
Reviewer's Cheat Sheet
Reviewer's Cheat Sheet
More like this