jackson-core: Jackson bundles are missing OSGi's osgi.serviceloader metadata
Bundles need to include extra metadata to support java.util.ServiceLoader
inside an OSGi framework. Jackson’s bundles are all missing this metadata.
In theory, it should just be a matter of applying Bnd’s @ServiceConsumer
and @ServiceProvider
annotations in the correct places as described here, where these annotations can be provided like this:
diff --git a/base/pom.xml b/base/pom.xml
index 6235a67..4972957 100644
--- a/base/pom.xml
+++ b/base/pom.xml
@@ -30,9 +30,17 @@ of Jackson: application code should only rely on `jackson-bom`
parent pom, and then also allow override as need be
-->
<jackson-bom.version>${project.parent.version}</jackson-bom.version>
+
+ <version.bnd.annotation>6.3.1</version.bnd.annotation>
</properties>
<dependencies>
+ <dependency>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>biz.aQute.bnd.annotation</artifactId>
+ <version>${version.bnd.annotation}</version>
+ <scope>provided</scope>
+ </dependency>
<dependency> <!-- all components use junit for testing -->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
I am struggling to wrap my head around your myriad of separate repositories, and so you may have a better way of providing this dependency.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (18 by maintainers)
Commits related to this issue
- Add minimal OSGi metadata as per #768 — committed to FasterXML/jackson-core by cowtowncoder 2 years ago
- Add minimal OSGi metadata as per #768 (#805) — committed to FasterXML/jackson-core by cowtowncoder 2 years ago
- Update release notes wrt #768 — committed to FasterXML/jackson-core by cowtowncoder 2 years ago
- Revert #768 — committed to FasterXML/jackson-core by cowtowncoder 2 years ago
Ok good, thank you for confirming @rakeshk15.
The solution to that is to make the requirement optional, as has already been done with Woodstox. I’m sorry, I thought we already knew this?
jackson-core
contains META-INF/services/com.fasterxml.jackson.core.JsonFactory, which means that it “provides” the classes inside this file asServiceLoader
“services”. As a rule, the classes listed insideMETA-INF/services/*
files need to be annotated as@ServiceProvider
, and classes which directly invokeServiceLoader.load(...)
need to be annotated as@ServiceConsumer
. These annotations instruct the Maven plugin to generate extra OSGi metadata inside the bundles, which can be used by OSGi’s Service Loader MediatorThe story becomes more complicated with
jackson-databind
because e.g.jackson-databind-xml
usesXMLInputFactory.newFactory()
etc which useServiceLoader.load(...)
indirectly. The Apache Aries SPI-Fly bundle supports extra OSGi metadata for cases like these. I know there is an issue with at leastjackson-databind-xml
andwoodstox-core
because I have tripped over it.