Preparing for Confluence 9.0 - EAP out now

I am having Jackson issues on m97(EDIT: and still on m116) now that I’m doing rest-v2 migration. We have been using jackson-databind for a while and have historically bundled our jackson packages. When instantiating our ObjectMapper we’re modifying it, also putting in additional modules like AfterBurnerModule and jsr310.JavaTimeModule.

According to the rest v2 upgrade guide, it seems like it is advising to change scope to provided, and can add provided scope to all jackson stuff like the modules:

<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-annotations</artifactId>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.datatype</groupId>
  <artifactId>jackson-datatype-jsr310</artifactId>
  <scope>provided</scope>
</dependency>

However, when adding osgi imports for com.fasterxml.jackson.module/datatype, it fails. I also see that jsr310 is tagged as private:


2024-06-11 12:59:35,893 WARN [UpmAsynchronousTaskManager:thread-4] [osgi.hook.dmz.DmzResolverHook] filterMatches Package com.fasterxml.jackson.datatype.jsr310 is internal and is not available for export t
o plugin no.kantega.kerberosauth.kerberosauth-plugin
2024-06-11 12:59:35,894 WARN [UpmAsynchronousTaskManager:thread-4] [osgi.hook.dmz.DmzResolverHook] filterMatches Package com.fasterxml.jackson.module.paramnames is internal and is not available for export
 to plugin no.kantega.kerberosauth.kerberosauth-plugin
[........]
Caused by: org.osgi.framework.BundleException: Unable to resolve no.kantega.kerberosauth.plugin [300](R 300.0): missing requirement [no.kantega.kerberosauth.plugin [300](R 300.0)] osgi.wiring.package; (os
gi.wiring.package=com.fasterxml.jackson.module) Unresolved requirements: [[no.kantega.kerberosauth.plugin [300](R 300.0)] osgi.wiring.package; (osgi.wiring.package=com.fasterxml.jackson.module)]
        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 com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:408)

Edit: checked with m116, same issues still there. We don’t have the available osgi exports for the needed jackson modules:

2024-06-11 13:12:25,815 INFO [ThreadPoolAsyncTaskExecutor::Thread 3] [atlassian.ratelimiting.internal.RateLimitingConfiguration] userRequestHandler Rate Limited Request Handler ENABLED
2024-06-11 13:12:25,879 WARN [Catalina-utility-1] [osgi.hook.dmz.DmzResolverHook] filterMatches Package com.atlassian.rest.annotation is internal and is not available for export to plugin no.kantega.kerbe
rosauth.kerberosauth-plugin
2024-06-11 13:12:25,905 WARN [Catalina-utility-1] [osgi.hook.dmz.DmzResolverHook] filterMatches Package com.fasterxml.jackson.datatype.jsr310 is internal and is not available for export to plugin no.kante
ga.kerberosauth.kerberosauth-plugin
2024-06-11 13:12:25,908 WARN [Catalina-utility-1] [osgi.hook.dmz.DmzResolverHook] filterMatches Package com.fasterxml.jackson.module.paramnames is internal and is not available for export to plugin no.kan
tega.kerberosauth.kerberosauth-plugin
2024-06-11 13:12:25,945 WARN [Catalina-utility-1] [osgi.hook.dmz.DmzResolverHook] filterMatches Package net.sf.cglib.proxy is internal and is not available for export to plugin no.kantega.kerberosauth.ker
berosauth-plugin
2024-06-11 13:12:25,946 WARN [Catalina-utility-1] [osgi.hook.dmz.DmzResolverHook] filterMatches Package org.apache.commons.lang is internal and is not available for export to plugin no.kantega.kerberosaut
h.kerberosauth-plugin
2024-06-11 13:12:25,946 WARN [Catalina-utility-1] [osgi.hook.dmz.DmzResolverHook] filterMatches Package org.apache.commons.lang.time is internal and is not available for export to plugin no.kantega.kerber
osauth.kerberosauth-plugin
2024-06-11 13:12:25,954 WARN [Catalina-utility-1] [osgi.hook.dmz.DmzResolverHook] filterMatches Package org.codehaus.jackson.annotate is internal and is not available for export to plugin no.kantega.kerbe
rosauth.kerberosauth-plugin

Edit #2: I was stuck between two choices. Either like above, be stuck without ability to use modules Atlassian chooses not to osgi export, or bundle jackson like we used to but suffer a conflict with Atlassian’s own jackson databind.

If bundle the jackson artifacts into the plugin, the ChainingClassLoader in the rest-v2 code grabs our plugin’s classloader and invokes a ClassNotFoundException looking for jackson databind modules for the rest-v2 ObjectMapper.

Solution
Maven-shade-plugin. The above bundling of jackon was only solved by using maven-shade-plugin to relocate our plugin’s com.fasterxml.jackson classes.

1 Like