question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OSGI service loader resolution should be optional

See original GitHub issue

Perhaps I am missing something, and someone with more experience interweaving java service loader and OSGI can explain why this resolution is not optional:

https://github.com/ical4j/ical4j/blob/9b82efeb7dc5ff0d2df238114225d157009ce96d/bnd.bnd#L3

It seems to me that this bundle is the bundle that is going to provide services under the package net.fortuna.ical4j.model.*

What I am experiencing is that the services are not registered until the bundle starts, and the bundle can’t start until something satisfies the requirement.

My testing shows that the bundle starts fine in an OSGI environment if “;resolution:=optional” is added to the end. E.g.: Require-Capability: osgi.extender;filter:="(osgi.extender=osgi.serviceloader.processor)", osgi.serviceloader;filter:="(osgi.serviceloader=net.fortuna.ical4j.model.*)";cardinality:=multiple;resolution=optional

Additionally, the bundle starts fine if I use another bundle to register something useless under that package name; thus satisfying the requirement.

I believe making the resolution optional makes sense because this bundle doesn’t actually require another bundle to make the services available; however as per the spec, services provided by a different bundle under that namespace would still be visible to this bundle.

This is a fairly trivial non-breaking change, but would allow us to continue using this project, and it would be greatly appreciated if someone could consider this.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
benfortunacommented, Dec 3, 2020

Ok I’ve submitted a PR to fix the typo

1reaction
viliuszcommented, Nov 19, 2020

Considering this issue is still open and relevant, hence posting here.

In most recent release version (3.0.20) MANIFEST.MF file has resolution=optional where it should be resolution:=optional (notice missing : (colon) after resolution).

Repackaging jar with updated MANIFEST.MF will remove errors from logs when loading.

Read more comments on GitHub >

github_iconTop Results From Across the Web

133 Service Loader Mediator Specification - OSGi Docs
Service Loader - An API in Java SE that allows a Consumer to find an implementation of a Service Type from a Service...
Read more >
How to create a working OSGi bundle with optional package ...
The way to tell if the package is available at runtime is to attempt to load a class from it and be prepared...
Read more >
Unraveling Java and OSGi class loader problems
Learn how to address common Java and OSGi class loader problems in CICS OSGi and Liberty JVM servers.
Read more >
OSGi Modularity and Services - Tutorial - Vogella.com
Defines an optional activator class which implements the ... The Bundle-ClassPath specifies where to load classes from the bundle.
Read more >
Meld OSGi Bundles with Java Modules
filter:=(&(osgi.wiring.bundle=java.prefs)(bundle-version=10.0.2)(java-module=true)) visibility:=reexport resolution:=mandatory osgi.serviceloader.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found