I think the syntax is "resolution:=optional" since that is a directive, not a matching attribute.
On Sat, Jan 14, 2023, 12:27 Roy Teeuwen <r...@teeuwen.be> wrote: > Hey all, > > I am creating an OSGi bundle that has some OSGi services which import > packages that might or might not be available in the OSGi environment. I > want the bundle to become active, but the OSGi services itself to not > become active if the packages are not available to be imported. > > I already stated in the Import-Package: > com.optional.package.*;resolution=optional,* and the Manifest.MF file seems > to be ok, but when I install the bundle, I still get the following > exception: > > 14.01.2023 17:23:12.350 *INFO* [OsgiInstallerImpl] > org.apache.sling.installer.core.impl.tasks.BundleStartTask Could not start > bundle test-bundle [225]. Reason: {}. Will retry. > org.osgi.framework.BundleException: Unable to resolve test-bundle [225](R > 225.5): missing requirement [test-bundle [225](R 225.5)] > osgi.wiring.package; > (&(osgi.wiring.package=com.optional.package.mailer)(resolution=optional)(version>=6.0.0)(!(version>=7.0.0))) > Unresolved requirements: [[test-bundle [225](R 225.5)] osgi.wiring.package; > (&(osgi.wiring.package=com.optional.package.mailer)(resolution=optional)(version>=6.0.0)(!(version>=7.0.0)))] > at > org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4398) > at org.apache.felix.framework.Felix.startBundle(Felix.java:2308) > at > org.apache.felix.framework.BundleImpl.start(BundleImpl.java:1006) > at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:992) > at > org.apache.sling.installer.core.impl.tasks.BundleStartTask.execute(BundleStartTask.java:97) > [org.apache.sling.installer.core:3.12.0] > at > org.apache.sling.installer.core.impl.OsgiInstallerImpl.doExecuteTasks(OsgiInstallerImpl.java:918) > [org.apache.sling.installer.core:3.12.0] > at > org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:755) > [org.apache.sling.installer.core:3.12.0] > at > org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:304) > [org.apache.sling.installer.core:3.12.0] > at java.base/java.lang.Thread.run(Thread.java:833) > > What can I do to make the bundle become active and ignore the OSGi > services that have optional requirements that are not available? > > Thanks! > Roy