Strange character encoding

Viewed 1228

I have a project that runs on WebSphere Liberty on Linux. My language is brazilian portuguese and we have some accented words. My java code sets some user messages like below:

...
ErroResponse erroResponse = new ErroResponse();
erroResponse.setMensagem("Esse grupo não pode ser criado. Já existe um grupo criado com esse nome.");
response = Response.status(Status.BAD_REQUEST).entity(erroResponse).build();
...

When the same message is show to the user, it looks this way: enter image description here

I don't think it's a browser encoding problem because the message looks the same on my server logs. enter image description here

I've tried to set JVM encoding using -Dclient.encoding.override -Dfile.encoding to ISO-8859-1 and UTF-8, without success.

The same project, running on a Windows server, runs without problem, showing the messages with the correct accents.

Only message that were directly written in the source code has this problem. Accented words that came from database query result are correctly presented.

I'm using Suse 11.4.

I really appreciate any help.

Thanks

4 Answers

I've had a similar problem with maven and jax-ws service which returned bad characters (of text inside source code).

Resolved it by adding this to the parent maven project:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Related