troubleshooting Question

Java daemon under linux, file name encoding problem with start-stop-daemon

Avatar of numtech
numtech asked on
Linux OS DevJava
11 Comments3 Solutions3891 ViewsLast Modified:
Hello,

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 script.
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 script.
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?

Best regards,

Renaud
ASKER CERTIFIED SOLUTION
Mick Barry
Java Developer
Join our community to see this answer!
Unlock 3 Answers and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros