We have developped a Java 6 SSLSocket server that runs as a daemon under Debian 5.0 using the start-stop-daemon
in a /etc/init.d/ssl-server
We face a problem when accessing the filesystem with path containing non-unicode characters.
This problem occured only when starting the server using the daemon wrapper, but not when started within a user shell.
After some research we found out it was because the encoding of the file names inside the JVM was set by the system property "sun.jnu.encoding". And it this case, it was initialized to the value "ANSI_X3.4-1968" instead of "UTF-8".
So we tried to start the server with the command
java -Dsun.jnu.encoding=UTF-8 -jar server.jar
It was changing the System.property inside the JVM but had no real effect on the file encoding (I guess the property is overwritten to late, and the FileSystem object is already instantiated).
Finally we found a workaround by adding a command to set the locale of the shell instance of the linux daemon at the top of our /etc/init.d/ssl-server
LANG=fr_FR.UTF-8; export LANG;
It solved the problem when our daemon was lauched by monit
but not when it was lauched by puppetd (wich run as a user "puppet" wich has no shell).
For now we decided to prevent puppetd from rebooting our server, he is just killed and then restarted by monit.
Thow, I would like to understand fully the problem to learn from this time consuming problem we've just faced.
Can someone explain us what is really happening and what is the best practice?