Default Java File Encoding Question [off topic]

24 views
Skip to first unread message

d_v_s

unread,
Feb 2, 2016, 12:52:02 PM2/2/16
to FusionReactor
Hi all,

I realize this is totally not a FR question, but the FR folks have generally been the most helpful to me in troubleshooting issues so I hope I could beg  your indulgence :)

On several of my recent installs of CF the default Java File encoding is getting set to ASCII


On my test box the default is UTF8 – which is what I want, and which according to all the documentation I have found is what CF should be using by default.

 

There are no –D options being added anywhere to override on the test box.  The LANG and all the LOCALE settings are all identical on all boxes (UTF8 settings)

 

I am not finding anything that should be causing CF/Java to pick up ASCII.  From what I can tell the OS is using UTF8 - I am out of ideas of why Java thinks it should pick up ASCII

 

I am on Red Hat 6 – CF 11 patched up to HF7 – 64 bit.  CF - using the default Java that come with it: 1.7.0_51 


I worked with Adobe as much as I could and they decided it was an OS issue.  It likely is but where?  How does java pick up the default encoding?


Any ideas of where else to look?



#

# Adobe had me run this which returns ASCII on the boxes in question so they say it has to be OS

#  Fine but WHERE?  

#


<cfscript>

mysys = createObject("java", "java.lang.System");

               reader = createObject("java", "java.io.InputStreamReader");

               reader.init(mysys.in);

               system.javafileencoding = reader.getEncoding();


</cfscript>


<cfoutput>#system.javafileencoding#</cfoutput>



- Mods - if you feel this is too far afield feel free to delete - I posted on Adobe CF forums and have a whopping zero responses :)

Matt Turner (Fusion Team)

unread,
Feb 3, 2016, 4:45:59 AM2/3/16
to FusionReactor
Hi d_v_s,

The default encoding for java is specified by a property within the JVM called "file.encoding". This is evaluated to the particular encoding that is set through the locale of an OS. 

It is possible to override this I believe through a JAVA_TOOL_OPTIONS environment variable setting.

You simply need to to set the environment variable:

export JAVA_TOOL_OPTIONS="-Dfile.encoding="UTF-8"

before running the JVM. This should be picked up by the JVM and force it to run UTF-8 as the default encoding.

The code snippet provided by Adobe should help you validate the encoding has changed, but there should also be a stderr output saying Picked up "JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8"  .

This is a very peculiar issue, saying that your locale and lang settings are identical on both boxes, but maybe this override provided by the JVM may help solve your issue?

Matt
Fusion Team

d_v_s

unread,
Feb 3, 2016, 9:08:38 AM2/3/16
to FusionReactor
Y'know an IT guys knee jerk reaction to a PC issue?  "Did you reboot it?"

*sigh*

The developers reported that one of the boxes that had been showing ASCII was now showing UTF8.  

What?  But I didn't change a thing on that box except...  I had rebooted it to clear a memory issue.

So I tried on another box - sure enough as soon as I rebooted it the CF admin screen shows UTF8.  Repeated on 3 boxes now.  
My best guess is some combination of patching, and upgrading the OS/CF (maybe even FR? - which I did recently bring up to the latest) caused Java to lose its mind - or maybe some tmp file somewhere was 
cached, who knows but the reboot has solved the issue.

I appreciate you reading and give me some ideas.  I had been testing setting -Dfile.encoding=UTF8 in the CF jvm.config - but it fundamentally disturbed me that the default behavior had changed.

Glad to be back on solid footing (ish).

thanks for allowing this to be posted here.  FR folks are the best!
Reply all
Reply to author
Forward
0 new messages