devbox@COMPUTEC The Computec development blog

24Aug/102

ColdFusion vs. Railo on <cftransaction action=”rollback”>

While migrating one of our ColdFusion 8 servers to Railo I stumbled over a small problem with the cftransaction tag today. Consider this snippet of code:

<cftransaction action="begin">
	<cftry>
		<cfquery name="variables.qTestQuery" 
				datasource="#variables.strDs#">
			SELECT version();
		</cfquery>
		<cfcatch type="database">
			<cftransaction action="rollback">			
		</cfcatch>
	</cftry>
</cftransaction>
Done.

This was running fine on ColdFusion 8.0.1, Railo 3.1.2.019 on the other hand complained:

Start and End Tag has not the same Name [cftransaction-cfcatch]
5: </cfquery>
6: <cfcatch type="database">
7: <cftransaction action="rollback">
8: </cfcatch>
9: </cftry>

The issue is easily resolved - and probably won't hit you as long as you're using a more recent IDE with better Code Assist than DreamWeaver MX 2004, as this will automatically provide a closing tag for the <cftransaction action="rollback">. To make Railo happy, just use

<cftransaction action="rollback" />

or

<cftransaction action="rollback"></cftransaction>

The version with the self-closing tag makes more sense to me, though ColdFusion Builder will provide you with the latter variation.

Filed under: ColdFusion 2 Comments