Closed mnlipp closed 1 year ago
Digging further, I found that the hk2 service locator is used in FactoryFinder only. Session.java
uses the ServiceLoader
without the hk2 "wrapper" and therefore fails to load the providers.
Hello,
It was reported one OSGi issue here: https://github.com/eclipse-ee4j/angus-mail/issues/15
There is already a fix here, but not merged yet: https://github.com/eclipse-ee4j/angus-mail/pull/19
Do you think that fix is valid here?.
Do you think that fix is valid here?.
Issue #15 is completely independent, i.e. I had to work around that sun.security.util
issue in addition to the problem described here.
The proper fix for this issue (#629) -- both the missing import and the inconsistent usage of hk2 (https://github.com/eclipse-ee4j/mail/issues/629#issuecomment-1287850248) -- is actually to "fix" #630. This will make #629 obsolete (This is why I provided a PR for #630 rather than #629.)
The (interesting) discussion may have caused the focus to be lost. So only as a reminder: this issue is about the missing DynamicImport-Package: org.glassfish.hk2.osgiresourcelocator
(see initial description).
@mnlipp this was merged: https://github.com/jakartaee/mail-api/pull/633
Can we close this?
Can we close this?
No. If you don't have the OSGi service mediator in your environment, the fallback is to use the hk2 service locator. This can only be found if it is in your class path, i.e. if it is imported. Therefore you need the import (as it is properly done in jakarta-api).
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 codeIn 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 inMANIFEST.MF
and therefore the provider services are not found.How it should be For comparison:
jakarta.activation-api-2.1.0.jar
has in itsMANIFEST.MF
the line:which ensures that the class
org.glassfish.hk2.osgiresourcelocator.ServiceLoader
is in the classpath and theClass.forName
is successful.To Reproduce Steps to reproduce the behavior:
Expected behavior Provider should be found.