The Developer's Tidbit

August 7, 2008

ColdBox, Transfer, ColdFusion 8 – A timeout occurred while attempting to lock

Filed under: coldbox, coldfusion, transfer orm — Ben @ 9:35 pm
Tags: , , , ,

In final phase with the migration of www.civbox.com to a structured framework application running off ColdBox and Transfer ORM I encountered one recurring problem. No matter what paged was referenced or loaded the following error would be generated after a very long loading time.

A timeout occurred while attempting to lock DC5CF9189FA37B5CEE3AB11FD50F9E23.
The error occurred in C:\x\x\coldbox\system\coldbox.cfc: line 66
Called from C:\x\x\Application.cfc: line 69
Called from C:\x\x\coldbox\system\coldbox.cfc: line 66
Called from C:\x\x\Application.cfc: line 69

After a bit of QA with the developers of ColdBox as well as with my shared hosting provider we all came to an agreement that Transfer ORM combined with ColdBox required too many Java Classes (CFCs) to be loaded at start-up. This would normally not be a problem but a bug with Sun’s Java 1.6, which is used by ColdFusion 8 by default, causes the applications’ start-up to grind to a halt. When a site has only limited resources to feed off, such as those in a shared hosting environment, this bug is then compounded more so.

Unfortunately there was no immediate solution available for this problem other than this blog entry at Compound Theory. My hosting provider was unable to downgrade the Java version to 1.5, and tie that to ColdFusion 8. So the only option for me, other than to replace all the code and database queries being referenced by Transfer was to downgrade the hosting server to ColdFusion MX 7. This required a bit of tweaking with some of the pages and functions using CF8 syntax shortcuts, but other than that the downgrade went without a hitch.

The site now runs at a brisk pace and is trouble free.

July 30, 2008

ColdBox error: Invalid JSON & The document you are trying to decode is not in valid JSON format

Filed under: coldbox, coldfusion — Ben @ 12:40 pm
Tags: , ,

Upon migrating from ColdBox 2.52 over to ColdBox 2.6 I was caught out by a subtle but show stopping issue. Unfortunately the error thrown is not very precise as to the details of the error is or what exactly has triggered it.

Invalid JSON

Invalid JSON

Looking into the pages being called prior to the error you can see the line ..

Called from \coldbox\system\plugins\XMLParser.cfc: line 1013

So one can assume it is probably an issue with one of the XML file, yet which file is not mentioned. However the XML file itself is not the problem, rather it is the data contained within. As JSON or JavaScript Object Notion like XML is another form of human readable data interchange. Unlike XML though JSON is light weight and less complex.

Now if you read the official What’s New Guide for ColdBox 2.6 you can find the following heading ‘JSON notation for dynamic complex settings’.

The configuration file allowed for simple notation to create structures: {name:’luis’,active:’true’} and arrays: [1,2,3]. However, with the inclusion of the new json plugin, you can now declare full JSON syntax notations on ALL complex variables in the configuration file. So you can inflate queries, nested arrays, structures and so much more.

My slipup was that I was transferring an old ColdBox 2.52 coldbox.xml file for use in ColdBox 2.6. I had missed one of my Settings elements under YourSettings that used complex but invalid JSON style data structures. But it was easily fixed with a few single quotes here and there…

2.52 statement

<Setting name="TransferSettings"
value="{datasourceFile:config/datasource.xml.cfm,
transferFile:config/transfer.xml.cfm,
definitions:config/definitions}"/>

2.6 updated statement

<Setting name="TransferSettings"
value="{datasourceFile:'config/datasource.xml.cfm',
transferFile:'config/transfer.xml.cfm',
definitions:'config/definitions'}"/>

July 28, 2008

ColdFusion ColdBox, Transfer, JRun Error 500 EventHandlerException

I have recently re-programmed one of my sites to use the ColdFusion ColdBox framework combined with Transfer ORM, Object Relational Mapping. While these two tools are tremendous for creating code in, making repetitive and time consuming tasks a breeze. There was a problem. Unfortunately migrating the updated code-base from my testing server onto my production server, which is a shared hosting account with HostMySite has caused all kinds of trouble. So in the next few entries I will cover the cryptic error messages and various problems I encountered, and how I went about fixing them.

My first trouble was a generic JRun 500 handler error. After a bit of troubleshooting this error was triggered when Transfer was created as a ColdFusion object in ColdBox. ColdBox was not the issue though, as the error would prop up even when the code was isolated on its own.

JRun 500 capture

JRun 500 capture

After trawling through the JRun error dump and following the error triggers. I discovered that the errors were not even the fault of Transfer; rather there was a problem with the ColdFusion tag it was instigating.

<cfdbinfo datasource=”myDNS” username=”myName” password=”myPass”

name=”db” type=”version”>

It turns out the website’s DNS was using the MySQL 3 JDBC driver, not the ColdFusion MySQL 4/5 driver. This simple slipup caused the quite cryptic and website halting, JRun 500 server error whenever the CFDBINFO tag was used.

This is the problem with shared hosting combined with frameworks and tools. There is a higher possibility of trouble that can arise, which can be very difficult and time consuming to trace back and fix.

Blog at WordPress.com.