-
Notifications
You must be signed in to change notification settings - Fork 109
Description
Describe the bug
An attempt has been made to solve service loader problems in an OSGi environment with org.glassfish.hk2.osgi-resource-locator.
The presence of the required class org.glassfish.hk2.osgiresourcelocator.ServiceLoader
is detected with the code
private static boolean isOsgi() {
try {
Class.forName(OSGI_SERVICE_LOADER_CLASS_NAME);
return true;
} catch (ClassNotFoundException ignored) {
}
return false;
}
In order for this to work, class org.glassfish.hk2.osgiresourcelocator.ServiceLoader
must be in the bundle's classpath (jar becomes "bundle" in OSGi). But the required import is missng in MANIFEST.MF
and therefore the provider services are not found.
How it should be
For comparison: jakarta.activation-api-2.1.0.jar
has in its MANIFEST.MF
the line:
DynamicImport-Package: org.glassfish.hk2.osgiresourcelocator
which ensures that the class org.glassfish.hk2.osgiresourcelocator.ServiceLoader
is in the classpath and the Class.forName
is successful.
To Reproduce
Steps to reproduce the behavior:
- Deploy jakarta.mail-api-2.1.0.jar in an OSGi enviroment
- Attempt to use the IMAP provider
Expected behavior
Provider should be found.