Thursday, March 11, 2010

Issue: Non-ASCII characters change to inverted question mark (“¿”) after save

I was recently entering some content into a Confluence wiki page that included some non-ASCII characters, such as “→” (U+2192, "RIGHTWARDS ARROW") and “←” (U+2190, LEFTWARDS ARROW).  (I can easily type those characters using Alt+Numpad 26 and Alt+Numpad 27 respectively, since my Windows XP machine is set to Code page 437.) However, after saving the document and coming back and looking at it later, all such characters had been changed to inverted (upside down) question mark characters, “¿”.

Investigation revealed that the problem was that the underlying Oracle database to which the content was being saved was set to use the Western European character set ISO-8859-1, as opposed to a more comprehensive character encoding such as UTF-8.  Since ISO-8859-1 doesn’t include the “leftwards arrow” or “rightwards arrow” characters, Oracle converted those characters to the inverted question mark instead.

I wanted to share this here since this information might be helpful to anyone encountering a similar issue in a variety of different possible applications, not necessarily just Confluence.

Wednesday, March 03, 2010

Fix: Error starting JBoss: “Please check that you are in the bin directory when running this script.”

I’m currently attending a developer training class on a Java application that runs on the JBoss application server.  When running a .bat script provided by the trainer on my Windows XP machine that is supposed to start JBoss (among other things), I and several others in the class were having the script fail with this error:

Could not locate C:\path\bin\run.jar. Please check that you are in the bin directory when running this script.

The path from the error message was not the correct JBoss directory containing run.jar, jboss-4.2.0.GA\bin, but a different directory. Searching through the files on my local machine revealed that this error message was coming out of the run.bat file in that same jboss-4.2.0.GA\bin folder.

Looking at the source of run.bat, the script attempts to create and set a Windows environment variable named JBOSS_HOME. I noticed two lines in particular near the beginning of the file:

if "%OS%" == "Windows_NT" set DIRNAME=%~dp0%
if "%OS%" == "Windows_NT" set PROGNAME=%~nx0%

From other parts of run.bat, I suspected that the root cause of the problem was that DIRNAME was not being set correctly.

From a command prompt, I ran "echo %OS%" (no quotes) -- this returned a value of WINNT -- not a value of Windows_NT as expected by the script.

Oddly enough, in the Environment Variables dialog in the Control Panel, the OS variable is set to Windows_NT -- the value is apparently being overridden by something else running on my machine. From talking to others in the training class, who had the script work from home but not while at the office, the override is apparently being done by one of the login scripts that automatically runs at when we log in to the corporate network.

In any event, the solution/workaround that we came up with was simply to edit run.bat and remove the OS check in the two above-mentioned lines, resulting in the following:

set DIRNAME=%~dp0%
set PROGNAME=%~nx0%

This got JBoss up and running successfully, despite the "incorrect" OS environment variable value on our Windows workstations.