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.

Monday, February 08, 2010

Confluence wiki: Linking to a diff against a specific old page version

At my office, we use the Confluence wiki for knowledge management.  We recently had some design specifications for a project delivered to us by a 3rd-party consultant; we imported this documentation into Confluence to allow easy tracking of future changes made to the content.

I wanted to be able to add a link to each page along the lines of “click here to see the Confluence diff between the current version of this page, and the 2009 version,” where the aforementioned “2009 version” would be a specific old page version of the page that I would specify when I set up the link on each page.

Unfortunately, Confluence doesn’t provide an “out-of-the-box” way to provide "one click" access such a diff of a specific old page version against the latest version of the page.  You can create a link to a Confluence diff between two specific versions by using the diffpages.action or diffpagesbyversion.action pages that come with Confluence, but both of those take two hard-coded version IDs or page IDs as parameters; they don’t take a parameter or otherwise allow you to specify “latest” as one of the versions to compare.  So you could create a link to a diff between (say) version 1 and version 5 of a page, but that link would become obsolete as new versions beyond 5 were created.

I asked for advice on how to do this (in this thread) on the Atlassian Confluence forum, and got a helpful suggestion from “Rob L.” involving setting up a Confluence user macro to emit the current version of a page, which could then be embedded in a link to a diff page; however, in my Confluence instance at work, I am unable to get a new user macro set up, so while a good solution, it didn’t solve the problem for me.

I then tinkered a bit more on my own, and came up with a way to do this without the need for a user macro. The approach involves using raw HTML (via the Confluence {html} macro) to create a hyperlink with a dummy target (“href”), and then using Javascript (again using the {html} macro) to edit the link target to include the pageId of the Confluence page, which is accessible via the Javascript DOM.

Here's the Confluence markup:

{html}
  <a id="mydiffLink" href="#">Click here to view the diff.</a> 
  <script> 
    document.getElementById('mydiffLink').href=
      "http://myConfluenceHost/confluence/pages/diffpages.action 
      ?originalId=12345678&pageId=" + document.getElementById('pageId').value; 
  </script> 
{html} 

This solution uses diffpages.action rather than diffpagesbyversion.action since the code uses the Confluence page ID, not version ID.

When using this solution, the hard-coded "12345678" in the above example should be replaced with the actual page ID of the old page to compare against.

"http://myConfluenceHost" in the above example should also be replaced with the actual hostname of your Confluence server, of course.

Caveats: This approach relies on (1) the Confluence {html} macro being enabled, and (2) on the user viewing the page having Javascript enabled.

Monday, January 25, 2010

Fix: Thinkpad using Wireless LAN even when connected via wire

This morning, I noticed that my work laptop, a Thinkpad T60 running Windows XP, was using its wireless network connection, even though the machine was docked and plugged in to the wired LAN.  In Control Panel | Network Connections, the “Wireless Network Connection” showed “Connected,” but the “Primary Network Connection” showed “Disabled.”

Right-clicking the “Primary Network Connection” and selecting “Enable” from the context menu resulted in a “Connection Failed!” message in a popup window, with no further details on the problem.

I’m not sure how my “Primary Network Connection” became disabled in the first place, but I was able to re-enable it as follows:

  • In Control Panel |  Network Connections, right-click on “Primary Network Connection” and choose “Properties”
  • In the “Primary Network Connection Properties” dialog that appears, click the Configure button (near the top of the dialog).
  • In the dialog that appears, if a message appears stating that the device is currently disabled, click the “Enable Device” button.

That fixed the problem for me.  The wired connection started successfully, and the wireless connection disconnected automatically (as it normally does when the wired connection is active).

Thursday, January 14, 2010

Microsoft Office 2003: Ctrl+F1 closes the task pane

Just because I couldn’t find this information when I was searching for it now: In Microsoft Office 2003, the keyboard shortcut to close (hide) the task pane is Ctrl+F1.  (The task pane in Office 2003 is the panel on the right side of the window that is usually hidden, but opens to show certain information such as Help (upon a press of F1), “Getting Started”, the Office clipboard ring, and other items.) 

This shortcut applies to Word 2003, Excel 2003, and PowerPoint 2003 (possibly among others).