EJB over Http-invoker throws CommunicationException on Authentication Failure
Environment
- Red Hat JBoss Enterprise Application Platform (JBoss EAP)
- 7.2
- Enterprise Java Beans (EJB)
- Http-Invoker
- EJBException wrapping real exception caught in client code on authentication failure
Issue
-
A CommunicationException is thrown but ideally it would be an an AuthenticationException like with http-remoting
-
Log shows this message:
HTTP000005: Invalid response code 401 (full response ClientResponse{responseHeaders={www-authenticate=[Basic realm="LDAPRealm"], content-length=[77], content-type=[text/html], date=[Thu, 25 Jul 2019 00:16:43 GMT]}, responseCode=401, status='', protocol=HTTP/2.0})
Resolution
Apply CP5 or later
To restore the old behavior of throwing an IOException, set this system property, but note this is considered deprecated as the correct exception is an AuthenticationException:
-Dorg.wildfly.httpclient.io-exception-on-failed-auth=true
Root Cause
The http-invoker code is catching any http response that isn't 200 and throwing the same exception, so it isn't differentiating between communication and other errors.
Content from issues.jboss.org is not included.JBEAP-17353.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.