I have a POJO Java client that needs to call an EJB running in WildFly 22 (standalone mode). WildFly is running behind an AWS load balancer.
Everything is fine if I have only one copy of the EJB service running behind the load balancer, but it falls apart when I add a second copy. The issue appears to be that the client does not include the authorization header on the initial request. The initial request goes through the load balancer to EJB copy A. EJB copy A responds that authentication is required
[io.undertow.request] (default I/O-8) Matched prefix path /wildfly-services for path /wildfly-services/ejb/v1/invoke/...
[io.undertow.request.security] (default I/O-8) Setting authentication required for exchange HttpServerExchange{ POST /wildfly-services/ejb/v1/invoke/...
The client then goes back through the load balancer to resend the request with the JSESSIONID cookie and the authorization header. Since the load balancer round-robins between services connected to it, this response hits EJB copy B instead of A, and EJB copy B doesn't have a clue what to do with it. The client ends up in an endless loop trying to authenticate with the server.
Is there a way to configure the client to force it to send the authorization header with the initial request?
Thanks!