Java charset encoding issue

Two servers running the same version of Java output/print characters differently. For example, on the working server "é" gets handled correctly however the other servers outputs/writes this character as "?".

Java version is 1.7.0_01-b08 and Tomcat on both servers is 7.0.54.

Both servers have the exact same output for:

uname -a
java -version
export | grep LANG

Both servers seem to 'echo' the character without issue from the command line, even writing a compiling a java program to export a file with the characters works correctly. The issue is only present via the java web app running on Tomcat. The exact same code base is running on both servers, so we don't believe it's the code.

Is there anything else i should be looking at?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Is there any difference regarding UTF8 in LC_* variables (like LC_ALL) and in java properties (-Dxxx=*UTF8* parameters)?
Tomas Helgi JohannssonCommented:

Check if the difference is in the Tomcat default locale or in locale of the the applications config file.

     Tomas Helgi
Amitkumar PSr. ConsultantCommented:
Please follow below steps:

1. check the locale on your servers using "locale -a" command. if results on both server are not same, then make it same for both the servers.

2. If #1 not worked, then check JAVA_OPTS in tomcat for both the servers.  It should contain JVM properties like "-Duser.language=en -Duser.region=US". Again, if its not the same on both tomcate, make it same for both.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

mccarlIT Business Systems Analyst / Software DeveloperCommented:
The issue is only present via the java web app running on Tomcat.

Where are you seeing these characters? Are you printing something to the console, are they in the log files or is it characters that are rendered at the browser?
zequestionerAuthor Commented:
Thanks everyone! Very odd, but this turned out to be a difference with the Jenkins deploy job using the service command.

From the man page -
"service runs a System V init script in as predictable environment as possible, removing most environment variables and with current working directory set to /.”
In short, don’t expect your app to take into account any environment variables, other then the one's specified in the startup script itself, if you use the service command.
So, Export LANG=en_US.UTF-8 is a pretty good line to have in your startup script

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zequestionerAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for zequestioner's comment #a40924673

for the following reason:

Odd issue, very helpful suggestions but the solution was unpredictable for EE experts.
Your solution is alias of first 3 comments.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.