I'm trying to deploy a wicket-6 application into a kubernetes cluster in order to increase availability and distribute the load of the web application a bit better.

This is a stateful web application in the sense that I'm extending AuthenticatedWebSession. It's this session object that I would like to store in a distributed cache like Apache Ignite so that I don't need sticky session on my load balancer.

The issue is that my implementation has the AuthenticationManager injected into the AuthenticatedWebSession so the authManager can be used in the authenticate(username, password) method.

@SpringBean(name = "webAuthenticationManager")
private AuthenticationManager authManager;

public boolean authenticate(String username, String password) {

    boolean authenticated = false;
    try {
        authentication = authManager.authenticate(new UsernamePasswordAuthenticationToken(username, password));
        authenticated = true;
    } catch (AuthenticationException e) {
        authenticated = false;
    return authenticated;

Caused by: org.apache.ignite.binary.BinaryObjectException: Failed to read field [name=authManager]
at org.apache.ignite.internal.binary.BinaryFieldAccessor.read(BinaryFieldAccessor.java:192)
at org.apache.ignite.internal.binary.BinaryClassDescriptor.read(BinaryClassDescriptor.java:875)

The issue arrises when Ignite tries to serialise / deserialise the authManager field. I actually don't need the manager itself to be stored in the cache.

Is there a way to re-inject that object when the session is restored from the cache?

Maybe I'm handling this completely wrong. Kind feel like I'm going down a rabbit hole here :)

1 Answers

martin-g On

Since it is a @SpringBean the instance is a java.lang.reflect.Proxy or CGLIB Proxy. Proxies are easy to (de)serialize because they don't keep the real instance as a hard reference. They look up the Spring bean dinamically via Spring's application context. See the sources of the classes in wicket-spring module. They are just a few of them. If Ignite uses normal Java Serialization then it should just work but maybe there is something custom.