After Upgrading to Wildfly 39 Base64 encoding throws an error

4 weeks ago 22
ARTICLE AD BOX

Well, You did nothing wrong. You stumbled across an error in the jakarta bind api, which got incorporated in wildfly 39.0.0 and did not get fixed in 39.0.1 (although a fix was available since a week before release).

In 4.0.4 of the jakarta bind api, a validation was included that base64 strings to be decoded should have a length dividable by 4, which is almost correct, as base64 allows for whitespaces to be included in the encoded string, which get ignored during decode. 4.0.4 counts those whitespaces into the overall length so if your string spreads across multiple lines (and the number of thos lines is not dividable by 4) you get that IllegalArgumentException.

A fix for the bind-api has been released in version 4.0.5. You can simply override the module of the wildfly with a fixed version. To do so, unzip your wildfly distribution. Go into directory wildfly-39.0.1.Final/modules/system/layers/base. From there copy the folder structure and files from the subdir jakarta/xml/bind/api/main into the directory wildfly-39.0.1.Final/modules.

You should now have a new directory wildfly-39.0.1.Final/modules/jakarta/bind/api/main and within that directory you should have two files, modules.xml and jakarta.xml.bind-api-4.0.4.jar. Download version 4.0.5 of the bind api from mvn-repo and place it in that directory, replacing version 4.0.4. Next edit modules.xml and replace 4.0.4 with 4.0.5 in the file name of the appropriate ressource-root tag.

You have now defined a custom xml-bind module and wildfly will assign your custom module a higher priority than the one shipped by default, so your corrected module overrules the broken one.

Hope, that saves you some time.

Cheers!

Read Entire Article