Skip to main content
Known Participant
September 1, 2010
Question

How do I do a runtime debug of a Coldfusion component file?

  • September 1, 2010
  • 1 reply
  • 3216 views

My application has a Coldfusion component(cfc), CFM file and a lot of Flex source files.

I tried using  <cftry>,  <cfcatch>, <cfdump> to find the errors in the cfc, but still cannot trace the issue.

The code in CFC file is somewhat like

<cfcomponent>
 
    <cffunction name="edit" access="remote" returntype="any">
        <cfargument name="form_data" type="struct">
        <cftry>
            <cftransaction>
           
                <!--- Update Record --->
                <cfquery datasource="#Application.ds#">
                    some SQL here
                </cfquery>
               
                 <!--- Remove all previous outcomes --->
                <cfquery datasource="#Application.ds#">
                    some SQL here
                </cfquery>
               
                <!--- Log Update --->
   
                <cfquery datasource="#Application.ds#">
                    some SQL here
                </cfquery>
               
                <!--- Get Last Logged Record --->
                <cfquery datasource="#Application.ds#" name="getLogLastRecord">
                    some SQL here
                </cfquery>
               
           
                 
                <cfloop index="arr_index" from="1" to="#ArrayLen(form_data.num)#">
                   
                    <!--- Update Record --->
                    <cfquery datasource="#Application.ds#" >
                        some SQL here
                    </cfquery>
                   
                    <!--- Log Update --->
                    <cfquery datasource="#Application.ds#" >
                        some SQL here
                    </cfquery>
                </cfloop>
 
           
    </cftransaction>
   
            <cfset result['statMsg']= "The record was saved successfully!">
            <cfset result['status']= true>
   
              
       
            <cfcatch><!--- Catch error --->
                <cfsavecontent variable="contentSaver">
                     <cfdump var="#form_data#">
                     <cfdump var="#cfcatch#">
                </cfsavecontent>
               
                <cffile action="write" file="#ExpandPath('.')#\debug.html" output="#contentSaver#">
               
                <cfset result['statMsg'] = cfcatch.Message>
                <cfset result['status']= false>
            </cfcatch>
        </cftry>
      
        <cfreturn result>
    </cffunction>
</cfcomponent>

Issue: 1 My understanding is if the transaction is successful I should get the message "The record was saved successfully!" which I don't get, though the transaction is successful as the data is saved in the MySQL backend.

Even if the transaction failed, I should get a message due to the catch block.

What could be the reason I am not getting the message? The users of the application need to get this so that they know that the changes they did are saved.

Issue 2: For another transaction, I get the below message at run time.

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@domain.com' at line 3"

The transaction goes through fine and changes are saved to the back end database which means nothing is wrong in my SQL syntax.

I don't see anything wrong on line 3 of the cfc file, nor the third line of the SQL statement has anything missing. Why am I getting that message?

Why am I not getting a message when I should for Issue 1 when the transaction is successful and why am I getting a strange error message for Issue 2 though the transaction is successful?

Can I do a run time debugging of the CFC using Coldfusion Builder as I can for Flex source files using Flexbuilder?

Any advice would be welcome.

This topic has been closed for replies.

1 reply

h_c1Author
Known Participant
September 1, 2010

Just to add, I checked the log files of Coldfusion in C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\logs



which were

application.log
derby.log
eventgateway.log
exception.log
mail.log
mailsent.log
server.log

and they also did not have the transaction success messages.

Where should this file be located? <cffile action="write"  file="#ExpandPath('.')#\debug.html" output="#contentSaver#"> The '.'  signifies in the current directory, but I cannot make out beyond that.

Sorry, but I am a newbie to Coldfusion and this application was created by another Coldfusion developer who left.
Participating Frequently
September 1, 2010

Yes, you can use debugger in ColdFusion Builder. Check http://help.adobe.com/en_US/ColdFusionBuilder/Using/WS0ef8c004658c1089-31c11ef1121cdfd6aa0-7fff.html for some details.

There are some interesting link around builder available on CF builder team blog - blogs.adobe.com/cfbuilder. [image links are not working becuase of admin issues]

h_c1Author
Known Participant
September 2, 2010

hemant_k wrote:

Yes, you can use debugger in ColdFusion Builder. Check http://help.adobe.com/en_US/ColdFusionBuilder/Using/WS0ef8c004658c1089 -31c11ef1121cdfd6aa0-7fff.html for some details.

There are some interesting link around builder available on CF builder team blog - blogs.adobe.com/cfbuilder. [image links are not working becuase of admin issues]

Thanks, that link is helpful.