apolloconfig/apollo · error · RuntimeException
Spring-session JSON deserializing error, This is usually cau
Error message
Spring-session JSON deserializing error, This is usually caused by the system upgrade, please clear the browser cookies and try again.
What it means
Thrown by the JDBC Spring-session converter in the reverse direction (byte[] -> Object) when objectMapper.readValue(source, Object.class) fails. The stored bytes no longer deserialize into a Java object, so the session cannot be restored and the request is rejected (HTTP 500). Like its serialize counterpart, the message attributes the cause to a system upgrade that changed the serialized class shape.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/SpringSessionConfig.java:61
@ConditionalOnProperty(prefix = "spring.session", name = "store-type", havingValue = "jdbc")
public ConversionService springSessionConversionService() {
GenericConversionService conversionService = new GenericConversionService();
ObjectMapper objectMapper = this.objectMapper();
conversionService.addConverter(Object.class, byte[].class, source -> {
try {
return objectMapper.writeValueAsBytes(source);
} catch (IOException e) {
throw new RuntimeException(
"Spring-session JSON serializing error, This is usually caused by the system upgrade, please clear the browser cookies and try again.",
e);
}
});
conversionService.addConverter(byte[].class, Object.class, source -> {
try {
return objectMapper.readValue(source, Object.class);
} catch (IOException e) {
throw new RuntimeException(
"Spring-session JSON deserializing error, This is usually caused by the system upgrade, please clear the browser cookies and try again.",
e);
}
});
return conversionService;
}
@Bean("springSessionDefaultRedisSerializer")
@ConditionalOnProperty(prefix = "spring.session", name = "store-type", havingValue = "redis")
public RedisSerializer<Object> springSessionDefaultRedisSerializer() {
return new GenericJackson2JsonRedisSerializer(objectMapper());
}
/**
* Customized {@link ObjectMapper} to add mix-in for class that doesn't have default constructors
*
* @return the {@link ObjectMapper} to use
*/View on GitHub (pinned to d95fc18d11)
Solutions
- Clear the affected browser cookies and the matching SPRING_SESSION rows, then authenticate fresh so a new session is written.
- Check portal logs for the wrapped IOException / InvalidFormatException to learn which attribute and field fail to deserialize.
- If you intentionally changed session attribute classes, flush all sessions in the DB after deploy.
- Keep the ObjectMapper returned by SpringSessionConfig.objectMapper() stable across releases (same default typing, same mix-ins).
Example fix
// before: stored session has a class that no longer exists -> readValue throws // (no code change fixes a corrupted row; you must drop it) // after: on upgrade, purge stale sessions, then users re-login DELETE FROM SPRING_SESSION WHERE CREATION_TIME < <upgrade_time>;
Defensive patterns
Strategy: retry
Try / catch
// A stale/corrupted session row usually recovers once the session is recreated.
try {
return portal.withSession(storedSession).call();
} catch (HttpServerErrorException e) {
if (e.getResponseBodyAsString().contains("Spring-session JSON deserializing error")) {
clearPortalCookies(); // discard JSESSIONID
return portal.freshLogin().call(); // retry once with a clean session
}
throw e;
} Prevention
- Treat a deserialization 500 as a signal to recreate the session, not as a hard failure.
- Purge SPRING_SESSION rows when changing session attribute class shapes.
- Pin portal and session schema versions together in deploy runbooks.
- Avoid long-lived sessions across upgrades.
When it happens
Trigger: A returning portal user whose session row was written by an older portal version (or a different ObjectMapper config) issues a request that needs to read the session, while spring.session.store-type=jdbc and the stored JSON no longer matches the current class structure.
Common situations: Portal upgraded across versions; session DB restored from a backup taken under another build; class refactored/renamed/moved package without a @JsonTypeInfo polymorphic mapping or default typing.
Related errors
- Spring-session JSON serializing error, This is usually cause
- Current user not found
- Portal user session is required
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/ed49a275262bfbdd.
Report an issue: GitHub.