Wrong encoding in validation messages - special characters are not diplayed

Hey,
I’ve got a weird problem (only) with my validation messages: all special characters get wrongly displayed
grafik

Here my investigation so far:
In other places in the form-model as you can see the special characters are diplayed correctly.
I also noticed that in the Redux store the content of .generatedCodeAccessor.script (where all those validation rules + error messages are saved by A12) the special characters where replaced, but in .content.modelRoot they where saved correctly. Therefore the error seems to occur somewhere in the generation of generatedCodeAccessor.script.
I also compared this to the store when displaying the form model with the UI-Designer, where those errors do not occur.
grafik

Does anybody have an idea, what the source of the problem could be and how this could be fixed?

TIm, which A12 Version are we talking about please?

I am using A12 2022.02ext2
for completeness the versions of the (probably) relevant modules:
@com.mgmtp.a12.base/base-model-api”: “25.0.2”,
@com.mgmtp.a12.client/client-core”: “11.1.0”,
@com.mgmtp.a12.dataservices/dataservices-access”: “33.0.8”,
@com.mgmtp.a12.dataservices/dataservices-server-connector”: “33.0.8”,
@com.mgmtp.a12.formengine/formengine-core”: “33.1.1”,
@com.mgmtp.a12.kernel/kernel-core-runtime-api-ts”: “26.2.3”,
@com.mgmtp.a12.kernel/kernel-md-facade”: “26.2.3”,
@com.mgmtp.a12.overviewengine/overviewengine-core”: “33.1.0”,

I may have been wrong and its an encoding issue in the backend. The validationCode is the only request that answers in the encoding “ISO-8859-1”, which probably results in the special characters being not interpreted correctly.


I already tried to force the charset to be UTF-8 with

server.servlet.encoding.charset=UTF-8
server.servlet.encoding.force-response=true

in the application properties, but with no success.
Any idea what else I could try?

For anybody facing the same problem in the future: I found the source of the problem and implemented a (dirty) workaround.

Problem

For the mimetype application/javascript there is no explicit MessageConverter defined and the default spring StringHttpMessageConverter is used. When this instance is generated no predefined encoding (e.g. with server.servlet.encoding.charset=UTF-8 in the properties) is used but ISO-8859-1 is hardcoded as the default.

Solution

As a dirty workaround I overwrote the static final DEFAULT_CHARSET with java reflections. All special characters in the validation messages are now properly encoded and shown as expected.

Hi TIm, glad that you solved it, however I would hope we can solve this better than with a dirty workaround. We are trying to reproduce it and if we have better solution, we will place it here.

I found the source of the problem: in the projects we use the @EnableWebMvc annotation in the project.

Because of that org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport creates a StringHttpMessageConverter without any way to configure the charset.
grafik

I still don’t understand, why this problem only appeared with the A12-2022.02 release and not befor the update using A12-2021.06 (where we also used that annotation without any problems)

Update:
this annotation is also used in com.mgmtp.a12.dataservices.server.autoconfigure.ServerAutoConfiguration, so by using dataservices-server-spring-boot-autoconfigure you’ll get the same problem, even if you do not use the annotation yourself. This also explains why in one of the two projects we only had the issue after updating.

For this issue now an A12 bug ticket was opened. So for anybody looking a this thread in the future, any (re)solutions might be discussed there: <INTERNAL_LINK>