Event handler hits twice on request

ColdFusion Server 9 on Windows Server 2008 6.1
ColdBox 2.6.3

I have a simple event handler with a cfmail tag that emails a simple
test email.

  <cffunction name="testhandler" access="public" returntype="void"
output="false">
    <cfargument name="Event" type="coldbox.system.beans.requestContext">
    <!--- Logic --->
    <cfscript>
      var rc = event.getCollection();
    </cfscript>
        <cfmail SERVER="mail.xxxxxx.com"
        USERNAME="xxxx"
        PASSWORD="xxxx"
        subject="testing"
        from="no reply<noreply@xxxx.com"
        to="clint<webmaster@xxxx.com>"
        failto="clint<webmaster@xxxx.com>"
        replyto="clint<webmaster@xxxx.com>"
        type="text/html">
    #now()#
    </cfmail>
    <!--- Display --->
    <cfset Event.setValue('pageTitle',"Test")>
    <cfset Event.setValue('section',"default")>
    <cfset Event.setView("test/result")>
  </cffunction>

The event handler runs fine but the cfmail runs twice for no reason,
always. In the Coldbox Cache debug this handler shows 2 hits for every
request, isn't it supposed to be 1 hit?

What would possibly make a handler run twice? Here's my config:

<Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="http://www.coldboxframework.com/schema/
config_2.6.0.xsd">
  <Settings>
    <!--These settings are automatically overridden by the
environments.xml.cfm for development. These settings are for
production only, no need to change anything.-->
    <Setting name="AppMapping" value="" />
    <Setting name="AppName" value="mysticinsight" />
    <Setting name="ApplicationStartHandler" value="main.onAppInit" />
    <Setting name="CustomErrorTemplate" value="/includes/
generic_error.cfm" />
    <Setting name="CustomEmailBugReport" value="" />
    <Setting name="ColdboxLogsLocation" value="logs" />
    <Setting name="ConfigAutoReload" value="false" />
    <Setting name="DebugMode" value="false" />
    <Setting name="DebugPassword" value="xxxx" />
    <Setting name="DefaultEvent" value="general.index" />
    <Setting name="DefaultLogLevel" value="3" />
    <Setting name="EventName" value="event" />
    <Setting name="ExceptionHandler" value="main.onException" />
    <Setting name="EnableBugReports" value="true" />
    <Setting name="EnableColdfusionLogging" value="false" />
    <Setting name="EnableDumpVar" value="false" />
    <Setting name="EnableColdboxLogging" value="true" />
    <Setting name="EventCaching" value="true" />
    <Setting name="FlashURLPersistScope" value="session" />
    <Setting name="HandlersIndexAutoReload" value="false" />
    <Setting name="HandlersExternalLocation" value="" />
    <Setting name="HandlerCaching" value="true" />
    <Setting name="IOCFramework" value="" />
    <Setting name="IOCFrameworkReload" value="false" />
    <Setting name="IOCDefinitionFile" value="/config/Coldspring.xml" /

    <Setting name="IOCObjectCaching" value="true" />
    <Setting name="MessageboxStyleOverride" value="false" />
    <Setting name="ModelsExternalLocation" value="" />
    <Setting name="ModelsObjectCaching" value="true" />
    <!-- Uncomment More Model Integration Settings:
      <Setting name="ModelsSetterInjection" value="false" />
      <Setting name="ModelsDICompleteUDF" value="onDIComplete" />
      <Setting name="ModelsStopRecursion" value="" />
      <Setting name="ModelsDebugMode" value="true" />
    -->
    <Setting name="ModelsDebugMode" value="false" />
    <Setting name="MyPluginsLocation" value="plugins" />
    <Setting name="onInvalidEvent" value="" />
    <Setting name="OwnerEmail" value="webmaster@mysticinsight.com" /

    <Setting name="ProxyReturnCollection" value="false" />
    <Setting name="RequestEndHandler" value="main.onRequestEnd" />
    <Setting name="RequestStartHandler" value="main.onRequestStart" />
    <Setting name="RequestContextDecorator" value="" />
    <Setting name="ReinitPassword" value="xxxx" />
    <Setting name="SessionStartHandler" value="main.onSessionStart" />
    <Setting name="SessionEndHandler" value="main.onSessionEnd" />
    <Setting name="UDFLibraryFile" value="" />
    <Setting name="ViewsExternalLocation" value="" />
  </Settings>

  <!-- Your Settings (can be overritten in the environments.xml.cfm)-->
  <YourSettings>
    <Setting name="ColdBoxSideBar" value="false" />
    <Setting name="businessName" value="Mysticinsight.com" />
    <Setting name="development" value="0" />
    <Setting name="adminEmail" value="clint317@gmail.com" />
    <!-- Directories -->
    <Setting name="imageDir" value="/includes/images/" />
    <Setting name="advisorPicturesDir" value="/includes/
advisorpictures/" />
    <Setting name="advisorThumbsDir" value="/includes/advisorpictures/
thumbs/" />
    <Setting name="jsDir" value="/includes/js/" />
    <Setting name="cssDir" value="/includes/css/" />
    <Setting name="emailTemplatesDir" value="/includes/
emailtemplates/" />
    <Setting name="webservicesDir" value="/webservices/" />
  </YourSettings>

  <DebuggerSettings>
        <PersistentRequestProfiler>true</PersistentRequestProfiler>
        <maxPersistentRequestProfilers>10</

        <maxRCPanelQueryRows>50</maxRCPanelQueryRows>
        <TracerPanel show="true" expanded="false" />
        <InfoPanel show="true" expanded="false" />
        <CachePanel show="true" expanded="false" />
        <RCPanel show="true" expanded="false" />
  </DebuggerSettings>

  <!--Optional,if blank it will use the CFMX administrator settings.-->
  <MailServerSettings>
    <MailServer>mail.xxxx.com</MailServer>
    <MailPort>25</MailPort>
    <MailUsername>xxxx</MailUsername>
    <MailPassword>xxxx</MailPassword>
  </MailServerSettings>

  <BugTracerReports>
  </BugTracerReports>

  <DevEnvironments>
     <url>127.0.0.1:8301</url>
     <url>localhost:8301</url>
  </DevEnvironments>

  <WebServices>
  </WebServices>

  <Layouts>
     <DefaultLayout>Layout.Default.cfm</DefaultLayout>
     <DefaultView>home</DefaultView>
     <Layout name="myaccount" file="Layout.MyAccount.cfm">
        <Folder>myaccount</Folder>
     </Layout>
     <Layout name="empty" file="Layout.Empty.cfm">
         <Folder>webmaster</Folder>
     </Layout>
  </Layouts>

  <i18N></i18N>

  <Datasources>
    <Datasource alias="DSN" name="xxxx" dbtype="mysql" username="xxxx"
password="xxxx" />
  </Datasources>

  <!--ColdBox Object Caching Settings Overrides the Framework-wide
settings-->
  <Cache>
    <ObjectDefaultTimeout>20</ObjectDefaultTimeout>
    <ObjectDefaultLastAccessTimeout>5</ObjectDefaultLastAccessTimeout>
    <UseLastAccessTimeouts>true</UseLastAccessTimeouts>
    <ReapFrequency>1</ReapFrequency>
    <MaxObjects>0</MaxObjects>
    <FreeMemoryPercentageThreshold>0</FreeMemoryPercentageThreshold>
    <EvictionPolicy>LFU</EvictionPolicy>
  </Cache>

  <!-- Interceptor Declarations -->
  <Interceptors>
    <!-- USE ENVIRONMENT CONTROL -->
    <Interceptor class="coldbox.system.interceptors.environmentControl">
      <Property name='configFile'>config/environments.xml.cfm</Property>
    </Interceptor>
    <!-- USE AUTOWIRING -->
    <Interceptor class="coldbox.system.interceptors.autowire">
      <Property name='enableSetterInjection'>true</Property>
    </Interceptor>
    <!-- USE SES -->
    <Interceptor class="coldbox.system.interceptors.ses">
      <Property name="configFile">config/routes.cfm</Property>
    </Interceptor>
    <Interceptor class="interceptors.visitorInterceptor"></Interceptor>
  </Interceptors>

  <!-- Custom Conventions -->
  <Conventions>
    <handlersLocation>events</handlersLocation>
    <pluginsLocation>plugins</pluginsLocation>
    <layoutsLocation>layouts</layoutsLocation>
    <viewsLocation>views</viewsLocation>
    <eventAction>index</eventAction>
    <modelsLocation>model</modelsLocation>
  </Conventions>

</Config>

are you in some kind of loop in you view file

No, the view file is completely empty except for 'Hello world.'
output.
Do you have any idea where I should start in the framework to trace
the issue, what file controls the actual firing of the handler etc..

Are you running ColdFusion Builder?

Regards,
Andrew Scott
http://www.andyscott.id.au/

Well, yeah I code in ColdFusion Builder. So how is that tied into my
issue *puzzled*? Thanks

I don’t use CFB myself, but perhaps he’s going to suggestion something to do with the debugger. :wink:

Is this just a test application? Do other handlers/events fire twice? Also, at what point(s) does the visitorInterceptor fire?

Jason Durham

Perfect reason to use CFBuilder’s Debugger!

You may also append an array you hold in your session with the stacktrace when it hits that page… You can generate a stack trace thanks to Ben Nadel (many thanks to Ben!) http://www.bennadel.com/blog/116-Finding-Template-Execution-Stack-in-ColdFusion.htm