0

I have a project running in a standalone WildFly that is working fine locally under Eclipse, but the same project running on WildFly in a remote server under Apache HTTP is getting special characters corrupted after submitting a file. For example:

Before submit a file:

Before submit a file

After submit a file:

After submit a file


OS: Linux

Using: JSF 2.2, Java 8, WildFly 10 and Apache HTTP 2.4

All the XHTML files are encoded with UTF-8 and the head contains the meta tag:

<meta http-equiv="restrict-type" content="text/html; charset=UTF-8" />

I've already tried:

→ Form with the 'charset' param in the enctype attribute:

<h:form id="fileForm" enctype="multipart/form-data;charset=UTF-8">

→ Running WildFly with the argument:

-Dfile.encoding=UTF-8

→ Enable the following option in httpd.conf:

AddDefaultCharset UTF-8

I don't know what I'm missing... Did anyone know a solution to this problem? I would appreciate any help. Thank you in advance and sorry for the bad English.

Renan Baggio
  • 411
  • 1
  • 4
  • 11

2 Answers2

1

with what character set is the OS running? what do you get from echo $LANG, echo $LC_CTYPE or echo $LC_ALL? Could be that somewhere the default charset of the OS is used.

I once had similar problems when running a Wildfly application in a Kubernetes pod on Google Container Engine. There was no encoding set at all, so I had to set the following environments variables before starting the application server:

ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8

So check what is set in your OS and set the env variables according to your needs before starting WildFly.

Edit: According to the comments, this seems to be a problem of the Apache running as proxy. I'm no specialist here, but perhaps this answer from superuser can help you further.

P.J.Meisch
  • 18,013
  • 6
  • 50
  • 66
  • Only `echo $LANG` returns something and it seems ok: **pt_BR.UTF-8**. Both my local machine and the server are with this value in $LANG. Can be something on Apache? – Renan Baggio Mar 30 '17 at 07:57
  • try to set LC_ALL as well; what I find strange is, that on first call, the display of the max size seems to be alright with máximo. So you have two servers running, WildFly and Apache? – P.J.Meisch Mar 30 '17 at 08:08
  • No, it's only one server. The whole system works fine, no problems with special characters, but when I submit a file on a multipart/form-data request the response is rendered with which seems another charset, corrupting the special characters. In my local machine, which is **not** running Apache and I'm acessing WildFly by localhost:8080, this doesn't happens. – Renan Baggio Mar 30 '17 at 08:23
  • So what does the server use the Apache for? Is this a proxy/gateway to the WildFly server? – P.J.Meisch Mar 30 '17 at 08:27
  • Yes, it's a proxy and proxy reverse to WildFly. I think can be something on Apache, but I haven't found the problem yet.. – Renan Baggio Mar 30 '17 at 08:31
  • Thanks for the edit response. I tried this solution but unfortunelly it doesn't solved the problem. Anyway, thanks @P.J.Meisch – Renan Baggio Mar 30 '17 at 17:03
0

After turning off Apache HTTP and acessing the system by IP:port the problem was still there.

Then I found a solution here: https://rogerkeays.com/servletrequest-setcharactercoding-ignored

I think a third-party lib was causing the damage, maybe it was the PrimeFaces Upload Filter. Now it works as expected after uploading a file.

Renan Baggio
  • 411
  • 1
  • 4
  • 11