Headless Linux, LylaCaptcha, BlogCFC and Bluedragon: Part 2

I left off with graphic manipulation working on CentOS and Bluedragon. At this point Lyla Captcha should be able to create an image, but it doesn't... Bummer. Keep in mind that part 2 is specific to Bluedragon 6.2. Hopefully it will work in BD7.

I started troubleshooting by creating the captchaTest.cfm test page from the LylaCaptcha zip file.

The first error was "No such function exists - isxml." This is caused around line 588 in the captchaService.cfc file.

<cfif NOT IsXML(rawXML)>
<cfthrow type="captchaService.notXML" message="The config file is not an XML file."/>
</cfif>

There is no IsXML() function in Bluedragon, so the reason for the error is obvious. I figured I could live without this check so I commented it out.

The second error was "Method charWidth is ambiguous as there is more than one method that could correspond to the provided argument types. If possible, use 'javacast()' to resolve this ambiguity." This is caused around line 263 of the same file.

<cfset left = left + ((RandRange(150, 200) / 100) * graphics.getFontMetrics().charWidth(char)) />

I created a test page and after some further testing, I found that charWidth() simply will not accept a character, only an integer. It should but it won't. Now I don't know if this is a Java problem or Bluedragon, but the bottom line is it simply will not work. Any time char is set to a character, it bombs.

I found this thread over at Ray Camden's forum and thanks to James Holmes (He knows more about this then I), he had a work-around for this. I replaced the above code with:

<cfset aCharacter = CreateObject("java", "java.lang.Character") />
<cfset left = left + ((RandRange(150,200) / 100) * graphics.getFontMetrics().charWidth(JavaCast("int",aCharacter.getNumericValue(char)))) />

I restarted Bluedragon, loaded up BlogCFC and I now have Lyla Captcha images!


Comments