Skip to content

fix: declare explicit dependency on jackson-annotations2-api#151

Closed
M0Rf30 wants to merge 1 commit into
jfrog:mainfrom
M0Rf30:fix/jackson-annotations-classloader
Closed

fix: declare explicit dependency on jackson-annotations2-api#151
M0Rf30 wants to merge 1 commit into
jfrog:mainfrom
M0Rf30:fix/jackson-annotations-classloader

Conversation

@M0Rf30
Copy link
Copy Markdown

@M0Rf30 M0Rf30 commented Apr 17, 2026

Summary

Fixes a java.lang.LinkageError (loader constraint violation) that prevents JfStep from initializing on Jenkins controllers running jackson2-api 2.19 or newer.

Problem

Starting with jackson2-api 2.19, the plugin was split: jackson-annotations was moved into a separate jackson-annotations2-api Jenkins plugin. The jfrog plugin still declares a dependency only on jackson2-api, so com.fasterxml.jackson.annotation.JsonInclude$Include is visible to BuildInfoExtractorUtils via one PluginClassLoader and to ObjectMapper.setSerializationInclusion(...) via another.

When JfStep.<clinit> calls BuildInfoExtractorUtils.createMapper the JVM sees two different Class objects for the same FQN and refuses method resolution:

java.lang.LinkageError: loader constraint violation: when resolving method
'com.fasterxml.jackson.databind.ObjectMapper
 com.fasterxml.jackson.databind.ObjectMapper.setSerializationInclusion(
  com.fasterxml.jackson.annotation.JsonInclude$Include)'
the class loader 'PluginClassLoader for jfrog'  ... and the class loader
'PluginClassLoader for jackson2-api' ... have different Class objects for
the type com/fasterxml/jackson/annotation/JsonInclude$Include ...
    at org.jfrog.build.extractor.BuildInfoExtractorUtils.createMapper(...:341)
    at io.jenkins.plugins.jfrog.JfStep.<clinit>(JfStep.java:46)

Fix

Declare io.jenkins.plugins:jackson-annotations2-api explicitly in pom.xml. The maven-hpi-plugin then emits it inside the Plugin-Dependencies manifest entry so Jenkins delegates annotation class loading through the same loader jackson2-api uses.

The dependency is pinned because the current bom-2.462.x does not manage jackson-annotations2-api yet.

Verification

Rebuilt plugin. The resulting HPI manifest now contains both plugin dependencies:

Plugin-Dependencies: ..., jackson-annotations2-api:2.21-7.v4777af3aad47,
 ..., jackson2-api:2.21.2-433.v6d50b92cfe52, ...

After installing the patched HPI on the affected controller the LinkageError no longer occurs and jf pipeline steps run as before.

Fixes #150

Test plan

  • CI builds the plugin
  • Install the resulting HPI on a Jenkins controller that has jackson2-api >= 2.19
  • Run a pipeline that uses tools { jfrog 'jfrog-cli' } and confirm JfStep initializes without a LinkageError

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 17, 2026

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@M0Rf30
Copy link
Copy Markdown
Author

M0Rf30 commented Apr 17, 2026

I have read the CLA Document and I hereby sign the CLA

jackson2-api 2.19+ split jackson-annotations out into a separate
jackson-annotations2-api Jenkins plugin. Because the jfrog plugin only
declared a dependency on jackson2-api, Jenkins loaded JsonInclude$Include
through two independent PluginClassLoaders, triggering a LinkageError
(loader constraint violation) in BuildInfoExtractorUtils.createMapper
when JfStep was initialized on controllers running jackson2-api 2.19 or
newer.

Declaring jackson-annotations2-api explicitly adds it to the generated
Plugin-Dependencies manifest entry so the annotation classes are
resolved through the same loader jackson2-api uses.

Fixes #150
@M0Rf30 M0Rf30 force-pushed the fix/jackson-annotations-classloader branch from 3abf107 to 70618ab Compare April 17, 2026 00:57
@M0Rf30 M0Rf30 closed this Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LinkageError on JfStep init: jackson2-api vs jfrog classloader conflict on JsonInclude$Include (jfrog 1.7.0)

1 participant