Migrating your application to the Jackson 3 based Cumulocity Java SDK

This guide is for developers whose applications (microservices, agents, test suites) depend on packages of cumulocity-clients-java (the Cumulocity Java SDK with its modules ).

The SDK has moved from Jackson 2 to Jackson 3 with version 2026.50.0. The Spring Boot 4 upgrade with SDK version 2026.43.0 deferred this by excluding spring-boot-starter-jackson and pulling in the spring-boot-jackson2 compatibility module; that shim is now gone from every SDK module.

What the SDK already handles for you. Jackson versions are managed through Spring Boot’s tools.jackson:jackson-bom (3.1.4 with Spring Boot 4.0.7) and inherited through the microservice-dependencies BOM. You do not need to declare Jackson versions.


Overview

After checking the prerequisites (chapter 0), the migration consists of five steps:

Step Chapter Who needs it
1 Dependency changes in your POM Everyone
2 Package moves and API changes (Java) Everyone
3 Behavior changes Everyone
4 LPWAN agents (lpwan-backend) Optional — only if you implement LnsConnection
5 Custom decoders / encoders Optional — only if you use the custom-decoders module

Steps 1 and 2 are mostly mechanical: the compiler finds most of what is missing, and section 2.1 lists the cases it does not. Step 3 needs the most attention: those changes compile cleanly and only show up at runtime or in tests. The quick reference checklist at the end summarizes all steps.


0. Prerequisites

  • Spring Boot 4. Jackson 3 and Spring Boot 4 are one step.
  • You may keep Jackson 2 on the classpath for your own code — Jackson 2 and 3 use different group IDs and different packages and coexist without conflict. But nothing in the SDK’s API speaks Jackson 2 any more, so anything touching SDK types has to move.

1. Dependency changes in your POM

1.1 Group IDs

Jackson 2 Jackson 3
com.fasterxml.jackson.core:jackson-core tools.jackson.core:jackson-core
com.fasterxml.jackson.core:jackson-databind tools.jackson.core:jackson-databind
com.fasterxml.jackson.datatype:* tools.jackson.datatype:*
com.fasterxml.jackson.module:* tools.jackson.module:*
com.fasterxml.jackson.core:jackson-annotations unchanged

Annotations stay on the old coordinates on purpose: per [JSTEP-1] Jackson 3 ships no annotations module of its own and keeps using the latest 2.x one (2.21 with Jackson 3.1.4). So every com.fasterxml.jackson.annotation.* import stays exactly as it is, and a Jackson 2 artifact remains on your classpath by design.

1.2 Remove the Jackson 2 shim

<!-- delete both of these -->
<exclusion>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-jackson</artifactId>
</exclusion>
...
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-jackson2</artifactId>
</dependency>

1.3 Delete jackson-datatype-jsr310

There is no 3.x release of that artifact. java.time support is built into jackson-databind
(tools.jackson.databind.ext.javatime) and is always on — remove the dependency and every JavaTimeModule registration.


2. Package moves and API changes (Java)

Mechanical renames:

Jackson 2 Jackson 3
com.fasterxml.jackson.core.* tools.jackson.core.*
com.fasterxml.jackson.databind.* tools.jackson.databind.*
com.fasterxml.jackson.datatype.* tools.jackson.datatype.*
com.fasterxml.jackson.annotation.* unchanged

Renamed types and methods:

Jackson 2 Jackson 3
JsonDeserializer ValueDeserializer (incl. ValueDeserializer.None.class)
JsonSerializer ValueSerializer
SerializerProvider SerializationContext
JsonProcessingException JacksonException
JsonGenerator.writeObject(Object) JsonGenerator.writePOJO(Object)
SerializationFeature.WRITE_DATES_AS_TIMESTAMPS DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS
SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS DateTimeFeature.WRITE_DURATIONS_AS_TIMESTAMPS
JsonParser.getCodec().treeToValue(…) DeserializationContext.readTreeAsValue(…)

2.1 Exceptions are unchecked :warning:

JacksonException extends RuntimeException, where JsonProcessingException extended
IOException. Two consequences:

  • throws JsonProcessingException clauses become JacksonException or can be dropped.
  • A catch (IOException e) that only ever caught Jackson errors is now an unreachable catch block, which is a compile error, not a warning. This is the most common break. Catch JacksonException instead. Where the try block also does real I/O, the IOException catch stays and a JacksonException catch is added next to it.

The compile error only catches the obvious cases. The ones below compile cleanly and fail at
runtime, typically as an HTTP 500 from a catch-all @ExceptionHandler(Exception.class) where a specific 4xx used to be returned, or as an exception escaping a method that used to wrap it.

catch (IOException) around real I/O and Jackson calls

When the try block also does real I/O, the IOException catch stays reachable, so nothing fails to compile — but Jackson errors no longer pass through it.

try {
    String bodyString = body.string();                 // real I/O
    return objectMapper.readValue(bodyString, clazz);  // throws JacksonException, not IOException
} catch (IOException | JacksonException e) {           // Jackson 2: catch (IOException e)
    throw new HttpClientException("Error occurred during reading response ...", e);
}

convertValue no longer throws IllegalArgumentException

Jackson 2 wrapped conversion failures in IllegalArgumentException. Jackson 3 throws the
underlying JacksonException subtype (for example MismatchedInputException), which is not an IllegalArgumentException. A catch (IllegalArgumentException e) around convertValue still compiles but no longer catches anything Jackson throws.

try {
    configurations = objectMapper.convertValue(fragment, new TypeReference<>() {});
} catch (IllegalArgumentException | JacksonException e) {   // Jackson 2: catch (IllegalArgumentException e)
    throw new InvalidScheduleConfigException(...);
}

Add a unit test with a fragment of the wrong shape (for example {} where a list is expected); tests that only cover a missing or null fragment never reach convertValue.

JsonNode accessors throw instead of returning defaults

Jackson 2’s JsonNode accessors returned a default for incompatible nodes. Jackson 3 throws JsonNodeException (a JacksonException):

Call on an incompatible node Jackson 2 Jackson 3
decimalValue() on "abc" 0 JsonNodeException
asInt() on "abc" or {} 0 JsonNodeException
asBoolean() on "abc" false JsonNodeException
asString() (Jackson 2: asText()) on {} "" JsonNodeException

Coercible values still work ("12".asInt() is 12, "true".asBoolean() is true), and null
or missing nodes (path(…)) still yield the default. Where input may be malformed, use the
overloads with an explicit default (asInt(0), asBoolean(false), …), which do not throw, or
check the node type first.

Example:

JsonNode params = mapper.readTree("{\"pos\": \"abc\", \"alreport\": \"yes\"}");

// Jackson 2: 0 and false. Jackson 3: JsonNodeException
int pos = params.get("pos").asInt();
boolean alreport = params.get("alreport").asBoolean();

// Jackson 3: 0 and false, as in Jackson 2; never throws
int pos = params.path("pos").asInt(0);
boolean alreport = params.path("alreport").asBoolean(false);

path(…) instead of get(…) also covers a missing parameter: get returns null (a
NullPointerException on the next call), path returns a missing node that yields the default. That is a behavior change in its own right — decide whether a missing parameter should be rejected rather than silently defaulted.

Finding affected code

Search for these patterns and check each hit:

  • catch (IOException in a try block that calls readValue, readTree, writeValueAsString or similar
  • catch (IllegalArgumentException around convertValue
  • JsonNode accessors (asInt(), asBoolean(), asString(), decimalValue(), …) on input that is not guaranteed to have the expected type

2.2 Mappers are immutable

ObjectMapper can no longer be reconfigured after construction — configure, registerModule, setSerializationInclusion and findAndRegisterModules are gone from the mapper. Build one instead:

// Jackson 2
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.setSerializationInclusion(NON_NULL);
mapper.registerModule(new JodaModule());
mapper.findAndRegisterModules();

// Jackson 3
ObjectMapper mapper = JsonMapper.builder()
        .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
        .configure(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS, false)
        .changeDefaultPropertyInclusion(inclusion ->
                inclusion.withValueInclusion(NON_NULL).withContentInclusion(NON_NULL))
        .addModule(new JodaModule())
        .findAndAddModules()
        .build();

new ObjectMapper() still compiles and still defaults to JSON, so plain usages need no change.

2.3 Customizing Spring’s auto-configured mapper

Because the mapper is immutable, a bean that mutated it after the fact no longer works. Contribute a builder customizer instead:

// no longer possible
@Autowired
public void configureJackson(ObjectMapper objectMapper) {
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

// Jackson 3
@Bean
public JsonMapperBuilderCustomizer failOnUnknownPropertiesDisabled() {
    return builder -> builder.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

Spring Boot’s auto-configured mapper bean is now a tools.jackson.databind.json.JsonMapper (@Primary, backed off by @ConditionalOnMissingBean). Injecting ObjectMapper still resolves to it, since JsonMapper extends ObjectMapper.


3. Behavior changes :warning:

Jackson 3 changed several defaults. For Spring-managed REST payloads, most of them do not actually change anything, because Spring Boot 3.x already overrode them (Jackson2ObjectMapperBuilder disabled DEFAULT_VIEW_INCLUSION and FAIL_ON_UNKNOWN_PROPERTIES; Jackson2AutoConfiguration disabled WRITE_DATES_AS_TIMESTAMPS and WRITE_DURATIONS_AS_TIMESTAMPS). What genuinely changes for your controllers:

Default Spring Boot 3.x Spring Boot 4 + Jackson 3 Effect
MapperFeature.SORT_PROPERTIES_ALPHABETICALLY off on JSON property order changes
MapperFeature.DETECT_PARAMETER_NAMES off on see below
WRITE_DATES_AS_TIMESTAMPS off off no change (already ISO-8601)
FAIL_ON_UNKNOWN_PROPERTIES off off no change (already lenient)
DEFAULT_VIEW_INCLUSION off off no change

Constructor binding is the one to watch. With DETECT_PARAMETER_NAMES on and the build compiling with -parameters, Jackson binds a multi-argument constructor by parameter name instead of going through the setters. A class whose setter normalizes, validates or escapes its input silently stops doing so. Lombok @Builder constructors make this common. Either annotate an explicit @JsonCreator, or turn implicit creator detection off for the type:

@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE)

3.1 Restoring Spring Boot 3.x behavior while you migrate

spring:
  jackson:
    use-jackson2-defaults: true

This makes the auto-configured mapper behave as it did under Spring Boot 3.x. It applies only to Spring’s mapper — mappers you construct yourself are unaffected — and it is a transition aid that will be removed, so treat it as temporary. Set it to false (or drop it) to adopt Jackson 3 behavior.

3.2 Standalone mappers that use @JsonView :warning:

JsonMapper.builderWithJackson2Defaults() does not restore MapperFeature.DEFAULT_VIEW_INCLUSION, and Jackson 3 defaults it to false where a plain Jackson 2 new ObjectMapper() had it true. If you replaced a new ObjectMapper() that is used with writerWithView / readerWithView, every property without a @JsonView annotation is now silently dropped from the output and read back as null. Add it explicitly:

JsonMapper.builderWithJackson2Defaults()
        .enable(MapperFeature.DEFAULT_VIEW_INCLUSION)
        .build();

This does nothing when no view is active, so it is safe to apply wherever you claim Jackson 2
defaults.

3.3 Standalone mappers and null for primitive fields :warning:

Jackson 3 enables DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES by default. A mapper you create yourself — including a plain new ObjectMapper() that needed no code change — now throws MismatchedInputException when the input has an explicit null for an int, long, boolean or other primitive field, where Jackson 2 silently used 0 / false. Missing properties are unaffected; only explicit null values fail.

This typically shows up with convertValue on managed object fragments, which may carry null values. It is what surfaced in the SNMP gateway in cumulocity-examples. Disable the feature on such mappers:

JsonMapper.builder()
        .disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
        .build();

JsonMapper.builderWithJackson2Defaults() also restores the old behavior. Spring Boot’s
auto-configured mapper is not affected.

3.4 Actuator endpoint output :warning:

Actuator endpoints (/env, /health, /info, …) are rendered by an isolated mapper that Spring Boot builds from plain Jackson 3 defaults (JacksonEndpointAutoConfiguration). With the Jackson 3 SDK this mapper is now in use; before, the SDK kept Jackson 3 off the classpath and actuator used Jackson 2. Because SORT_PROPERTIES_ALPHABETICALLY is on, properties now appear in alphabetical order — for example in /env:

Jackson 2:  "TZ":{"value":"Europe/Warsaw","origin":"System Environment Property \"TZ\""}
Jackson 3:  "TZ":{"origin":"System Environment Property \"TZ\"","value":"Europe/Warsaw"}

spring.jackson.use-jackson2-defaults (section 3.1) does not reach this mapper. Tests that match actuator responses as raw substrings break — this is what failed the “Should inject timezone environment” scenario in cumulocity-quality. Make such assertions order-independent by parsing the JSON. If you must keep the old output, management.endpoints.jackson.isolated-json-mapper=false makes actuator use the application’s mapper instead, which use-jackson2-defaults does affect.


4. LPWAN agents (lpwan-backend)

Optional. Only needed if your application depends on lpwan-backend and implements
LnsConnection (registered with LnsConnectionDeserializer.registerLnsConnectionConcreteClass(...)). Otherwise skip this chapter.

  • An LnsConnection implementation must declare the Jackson 3 annotation
    @tools.jackson.databind.annotation.JsonDeserialize(using = ValueDeserializer.None.class).
    Without it, deserialization recurses into LnsConnectionDeserializer until the stack
    overflows. The requirement is not new, but Jackson 3 ignores the Jackson 2 annotation
    (com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = JsonDeserializer.None.class)).
    That annotation still compiles when Jackson 2 databind reaches the classpath through another dependency, so a missed import does not necessarily show up as a compile error. LnsConnectionDeserializer.registerLnsConnectionConcreteClass(...) therefore checks the registered class (or one of its superclasses below LnsConnection) and throws an IllegalStateException naming the required annotation if it is missing, so the agent fails at startup instead of on the first read.

  • LnsConnection now carries @JsonAutoDetect(creatorVisibility = NONE) so that binding still goes through setName(), which escapes and normalizes the connection name. An implementation that declares an explicit @JsonCreator is unaffected.

  • LnsConnectionDeserializer now binds on the calling context and therefore honours an active @JsonView, where the Jackson 2 codec used the mapper’s view-less configuration. Spring applies a view to a request body only when @JsonView sits on the @RequestBody parameter (a method-level annotation affects the response only), so controllers are unaffected unless you do that.

5. Custom decoders / encoders

Optional. Only needed if your application depends on the custom-decoders module, for
example a decoder microservice implementing DecoderService, or an LPWAN codec built on lpwan-custom-codec (which pulls in custom-decoders). An encoder that only uses custom-encoders is not affected. Otherwise skip this chapter.

JacksonConfiguration in custom-decoders contributes a JsonMapper bean, which backs off Spring Boot’s auto-configured one. That mapper is pinned to Jackson 2 defaults so decoder and encoder results keep their wire format, and spring.jackson.use-jackson2-defaults has no effect on it. If you need Boot’s customizations (spring.jackson.*, @JsonComponent modules, mixins), define your own JsonMapper bean.


6. How long Jackson 2 remains an option

  • spring-boot-jackson2 ships deprecated and is a stop-gap. Spring Boot has stated the earliest removal is 4.3, May 2027.

  • Jackson 2 itself has no published end-of-life date. LTS branches stay open at least two years from their .0; 2.21 (LTS) was released January 2026, and the maintainers describe 2.x as receiving bug and security fixes “for years”, with new functionality going only to 3.x.

There is no hard deadline, but the SDK no longer offers a Jackson 2 path.


Quick reference checklist

  • Remove spring-boot-jackson2 and the spring-boot-starter-jackson exclusions
  • Move jackson-core / jackson-databind / jackson-datatype-* / jackson-module-* to tools.jackson.*
  • Leave jackson-annotations and every com.fasterxml.jackson.annotation.* import alone
  • Delete jackson-datatype-jsr310 and all JavaTimeModule registrations
  • Rename imports com.fasterxml.jackson.{core,databind,datatype} → tools.jackson.*
  • JsonDeserializer → ValueDeserializer, JsonSerializer → ValueSerializer, SerializerProvider → SerializationContext
  • LPWAN agents: LnsConnection implementation annotated with the Jackson 3 @JsonDeserialize(using = ValueDeserializer.None.class), no Jackson 2 JsonDeserialize import left
  • JsonProcessingException → JacksonException; fix unreachable catch (IOException) blocks
  • Add JacksonException to catch (IOException) blocks that also do real I/O
  • Add JacksonException to catch (IllegalArgumentException) blocks around convertValue
  • Use JsonNode accessors with explicit defaults (asInt(0), …) where input may be malformed
  • Move mapper configuration into JsonMapper.builder(); replace post-construction mutation with a JsonMapperBuilderCustomizer
  • SerializationFeature.WRITE_{DATES,DURATIONS}_AS_TIMESTAMPS → DateTimeFeature
  • Review classes whose setters normalize or validate, for constructor binding
  • Add DEFAULT_VIEW_INCLUSION to any standalone mapper used with @JsonView
  • Disable FAIL_ON_NULL_FOR_PRIMITIVES on standalone mappers whose input may carry null for primitive fields
  • Make tests that match actuator responses as raw strings independent of property order
  • Consider spring.jackson.use-jackson2-defaults=true as a temporary bridge
1 Like