Copy link to clipboard
Copied
Hi,
Using cf11 i've upgraded the Application.cfc to set a application specific datasource name, and application specific CustomTag path, and it work most of the time,
However from time to time, i get and email error report with "Cannot find CFML template for custom tag ", or "Attribute validation error for tag CFQUERY.The value of the attribute datasource, which is currently '', is invalid."
Thoses error goes away on the page refresh on next request....
<cfcomponent
displayname="Application"
output="true"
hint="Handle the application.">
<!--- Set up the application. --->
<cfset THIS.Name = "MonApp" />
<cfset THIS.ApplicationTimeout = CreateTimeSpan( 5, 0, 0, 0 ) />
<cfset THIS.sessionTimeout = CreateTimeSpan( 0, 9, 0, 0 ) />
<cfset THIS.SessionManagement = true />
<cfset THIS.SetClientCookies = true />
<cfset THIS.loginStorage = "Cookie" />
<cfset THIS.datasource = "maDS" />
<cfset THIS.rootDir = getDirectoryFromPath(getCurrentTemplatePath()) />
<cfset THIS.CustomTagPaths="#THIS.rootDir#/CustomTags/" />
<cfset THIS.CompileExtForInclude="cfm,cfml,inc,cnf,cfc" />
<cfset THIS.mappings["/includes"]="#THIS.rootDir#/includ/" />
<!--- Define the page request properties. --->
<cfsetting
requesttimeout="20"
showdebugoutput="TRUE"
enablecfoutputonly="false"
/>
<cffunction
name="OnApplicationStart"
access="public"
returntype="boolean"
output="false"
hint="Fires when the application is first created.">
<!--- Initialize the application settings. --->
<cfinclude template="../config/local.cnf">
<cfreturn true />
</cffunction>
<cffunction
name="OnRequestStart"
access="public"
returntype="boolean"
output="true"
hint="Fires at first part of page processing.">
<!--- Define arguments. --->
<cfargument
name="TargetPage"
type="string"
required="true"
/>
<cfset SetLocale("fr_FR") />
<!--- Return out. --->
<cfreturn true />
</cffunction>
<cffunction
name="OnRequest"
access="public"
returntype="void"
output="true"
hint="Fires after pre page processing is complete.">
<!--- Define arguments. --->
<cfargument
name="TargetPage"
type="string"
required="true"
/>
<cfif IsDefined("Form.logout") or IsDefined("URL.logout")>
<!--- cfset StructClear(session) / --->
<cfset StructDelete(session, "id") />
<cfset StructDelete(session, "rr") />
<cflogout />
</cfif>
<cfif StructKeyExists( URL, "reinit" )>
<cfset THIS.OnApplicationStart() />
</cfif>
<cfinclude template="gabarits/original/header.cfm" />
<cflogin idletimeout="14400">
<cfinclude template="login/main.inc" />
</cflogin>
<!--- FIX: reload sessions variables if lost since last login (bug ?) --->
<cfif not isDefined("Session.id") or not isDefined("Session.rr")>
<cfinclude template="login/session.inc" />
</cfif>
<!--- Include the requested page. --->
<cfinclude template="#ARGUMENTS.TargetPage#" />
<cfreturn />
</cffunction>
<cffunction
name="OnSessionEnd"
access="public"
returntype="void"
output="false"
hint="Fires when the session is terminated.">
<!--- Define arguments. --->
<cfargument
name="SessionScope"
type="struct"
required="true"
/>
<cfargument
name="ApplicationScope"
type="struct"
required="false"
default="#StructNew()#"
/>
<cflogout />
<!--- Return out. --->
<cfreturn />
</cffunction>
<cffunction
name="OnError"
access="public"
returntype="void"
output="true"
hint="Fires when an exception occures that is not caught by a try/catch.">
<!--- Define arguments. --->
<cfargument
name="Exception"
type="any"
required="true"
/>
<cfargument
name="EventName"
type="string"
required="false"
default=""
/>
<cfif isDefined("arguments.exception.Rootcause.message")>
<cflog file="sidys" text="#arguments.exception.Rootcause.message#">
<cfif isDefined("Application.prettyError") and Application.prettyError is 1>
<cfsavecontent variable="errortext">
<cfoutput>
An error occurred on: http://#cgi.server_name##cgi.script_name#?#cgi.query_string#<br />
Operation : #cgi.request_method#<br/>
Referrer: #cgi.http_referrer#<br/>
Url: #Iif(isDefined("CGI.HTTP_REDIRECT_URL"),de(CGI.HTTP_REDIRECT_URL),de("-"))#<br/>
Your Location : #cgi.remote_addr#<br/>
Time: #dateFormat(now(), "short")# #timeFormat(now(), "short")#<br />
<cfif isDefined("Session.id")>
Utilisateur: #Session.id.UserName# (#Session.id.UserID#).<br/>
<br/>
<cfdump var="#Session#" label="Session">
</cfif>
<h1>Exception</h1>
<cfdump var="#arguments.exception.rootcause#" label="Error">
<cfdump var="#variables#" label="Variables">
<h1>Detail parametres</h1>
<cfdump var="#form#" label="Form">
<cfdump var="#url#" label="URL">
</cfoutput>
</cfsavecontent>
<cfmail to="my@email.com" from="my@email.com" subject="Error: #arguments.exception.Rootcause.message#" type="html">
#errortext#
</cfmail>
<cfoutput>
<h1>Une erreur est survenue.</h1>
<p>Les details ont été directement envoyés à l'administrateur par email.</p>
<p>Prenez contact avec lui pour plus d'informations.</p>
<a href="javascript:history.back();">Revenir en arriere.</a>
</cfoutput>
<!--- Return out. --->
<cfelse>
<h1>Une erreur est survenue.</h1>
<h1>Exception</h1>
<cfdump var="#arguments.exception.rootcause#" label="Error">
<cfdump var="#variables#" label="Variables">
<h1>Detail parametres</h1>
<cfdump var="#form#" label="Form">
<cfdump var="#url#" label="URL">
</cfif>
<cfelse>
<cfthrow object="#arguments.exception#">
</cfif>
<cfreturn />
</cffunction>
</cfcomponent>
Have something to add?