Is assertion 'Apply JSON Transformation' not UTF-8 compliant?
search cancel

Is assertion 'Apply JSON Transformation' not UTF-8 compliant?

book

Article ID: 385621

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

We use the assertion 'Apply JSON Transformation' ( JsonTransformation-11.0.00.18016.aar) to convert a JSON message (request) to an XML request..

But if we use non-ASCII characters these characters are not converted.

 

Environment

Gateway 11.x container based

Resolution

To resolve this you can set the "-Dfile.encoding=UTF8" in the gateway system-properties file in  /opt/SecureSpan/Gateway/node/default/etc/conf/system.properties

The container gateway uses the environment variable "EXTRA_JAVA_ARGS", this variable defines any JVM properties to be added.

When using the helm charts this can be added to the JavaArgs section 

https://github.com/CAAPIM/apim-charts/tree/stable/charts/gateway#java-args

The default charset of the JVM is determined at the JVM startup and depends on the charset and locale of the underlying operating system.

https://techdocs.broadcom.com/us/en/ca-enterprise-software/layer7-api-management/api-gateway/congw11-1/reference/gateway-system-properties.html

For container based gateway's for GW 11.x  there are some additional steps to set the default file encoding for the JRE to UTF-8 see steps below as they are not installed by default on the OS image.

How to set the default locale in UBI 8 images ? (Container Gateway 11.x  is build on UBI )

Issue

  • How to set the default locale as en_US.utf8 in UBI 8 minimal image ?
  • The default locale for UBI 8 minimal image is set as C.utf8. How to change the default locale to en_US.utf8 ?
  • locale command is returning the C.utf8 in the UBI 8 image. How to change the locale to en_US.utf8?

Resolution

Install the required glib-langpack-XX while building the container. If the requirement is to set the default locale as en_US.utf8, then install the package glibc-langpack-en. Example:

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1
RUN microdnf install glibc-langpack-en; sed -i 's/^LANG=.*/LANG="en_US.utf8"/' /etc/locale.conf
set ENV LANG=en_US.utf8

Note: For UBI 8 image (not minimal), use yum/dnf command instead of microdnf command.

To find all the available langpack, execute the command yum search glibc-langpack'. With UBI 8 repos, onlyglibc-langpack-en` is shipped. So to find all the available packages, execute yum search on a registered RHEL node.
Root Cause
glibc-minimal-langpack is installed by default for C, POSIX and C.UTF-8 locales.