I'm using OpenLiberty (automatically downloaded through its maven plugin) and my application is working fine (jax-rs and servlet/jsp outputs are fine).
But the console (and messages.log) output is messy. Here is one example:
[INFORMAıåES] SRVE0253I: [io.openliberty.microprofile.health.3.0.internal] [/health] [HealthCheckServlet]: Destrui?Æo bem sucedida.
(expected is [INFORMAÇÕES] ... Destruição bem sucedida.
)
Clearly the messages are being printed as ISO-8859-1 in a UTF-8 capable terminal.
Again, this question is not about the application running inside OpenLiberty container, which is completely UTF-8 and working fine. It is about the console output.
A partially useful workaround would be to change its locale to en-US
(so that OpenLiberty's messages wouldn't need any special character). Actually, I'd prefer english error messages, because they are easier to google for.
I already tried LANG=en-US.UTF8
, LC_ALL=en_US
and LC_MESSAGES=en_US
, to no avail.
Project's effective pom.xml
already declares <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
. Every file in my project is UTF-8. Project's .editorconfig
[*] charset = utf-8
(so vscode creates every new file as utf-8).
I'm using bash MINGW64_NT-10.0-18363 + ConEmu-Maximus5 over Windows 10. LANG
defaults to =pt_BR.UTF-8
.
UPDATE
I've managed to set locale to en-US by adding
-Duser.language=en
to ${server.config.dir}/jvm.options
.
To be honest, I did it through liberty-maven-plugin:
<properties>
...
<liberty.jvm.language>-Duser.language=en-US</liberty.jvm.language>
...
</properties>
(and for liberty-maven-plugin
itself, I've added -Duser.language=en
to MAVEN_OPTS
)
Unfortunately, -Dfile.encoding=UTF-8
did nothing.
UPDATE 2
I'm also running OpenLiberty inside an Arquillian driven junit test. Interestingly, when launched by arquillian, OpenLiberty honors the -Dfile.encoding=utf-8
setting.
For arquillian it could be configured through arquillian.xml
:
<arquillian ...>
<container qualifier="liberty_managed" default="true">
<configuration>
...
<property name="javaVmArguments">-Dfile.encoding=utf-8</property>
...
</configuration>
</container>
</arquillian>
Or in ${server.config.dir}/jvm.options
(as I did before):
-Dfile.encoding=utf-8
My conclusion is that -Dfile.encoding
is the right way to approach this issue. But somehow when launched by liberty-maven-plugin
it is not honored. I'll take a closer look into its source code.