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
locale
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?
LVL 1
zequestionerAsked:
Who is Participating?
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.

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

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

Regards,
     Tomas Helgi
0
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.
0
The Firewall Audit Checklist

Preparing for a firewall audit today is almost impossible.
AlgoSec, together with some of the largest global organizations and auditors, has created a checklist to follow when preparing for your firewall audit. Simplify risk mitigation while staying compliant all of the time!

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?
0
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
0

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.
0
gheistCommented:
Your solution is alias of first 3 comments.
http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html
0
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
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.