0
votes

Looking through the logs, we're getting hundreds of the following

"Error","jrpp-185","08/21/12","10:05:43","PATH","www.domain.com 
Agent:Mozilla/4.0 (compatible; Synapse) 
Error: An exception occurred when invoking a event handler method from Application.cfc. 
The method name is: onRequest.

They seem to be mostly search bots. The on place on APplication.cfc that I can see reference to the function is below

<cffunction name="onRequest" returnType="void">
        <cfargument name="targetPage" type="String" required=true/>
        <cfsetting enablecfoutputonly="yes" requesttimeout="20">

        <cfparam name="url.refresh" default="0">
        <cfset request.strMember = Duplicate(session.strMember)/>

        <cfset request.tNow = GetTickCount()>
        <cfif url.refresh EQ 0>
            <cfset request.iCacheHr = 12/>
        <cfelse>
            <cfset request.iCacheHr = 0/>
        </cfif>

        <cflogin>
            <cfif IsDefined("session.strMember.sRoles")>
                <cfloginuser name="#session.strMember.sFirstName##session.strMember.sLastName#"
                    password="12345"
                    roles="#session.strMember.sRoles#"/>
            </cfif>
        </cflogin>

        <cfinclude template="core/incl/SessionLogger.cfm">
        <cfinclude template="core/incl/LinkTranslator.cfm">
        <cfinclude template="core/incl/udf.cfm">

        <cfinclude template="urlcheck.cfm"/>
        <cfinclude template="#Arguments.targetPage#">
    </cffunction>

From that, can anyone please advise on what's wrong and how to fix it? I'm fairly new to CF and this is making me pull out what little hair I have left

3
Element XMLHOMEPAGE is undefined in a CFML structure referenced as part of an expression. - pee2pee
Also Element STRMEMBER is undefined in SESSION - pee2pee
The second one - Element STRMEMBER is undefined in SESSION - is most likely causing your "Error: An exception occurred when invoking a event handler method from ..." Probably the best approach would be to set it to empty string by default. - Germann Arlington
<cffunction name="onSessionStart"> <cfscript> session.strMember = StructNew(); session.strMember.iMemberId = 0; session.strMember.lSecurityLevels = "Guest"; </cfscript>... this is where/how its set - pee2pee
Ok, seems the error is pointing to Element XMLZONE is undefined in REQUEST. and the code is <cfscript> variables.aZoneInfo = XmlSearch(application.xmlZones, "//zone[position() = 1]"); try { request.xmlZone = ToString(variables.aZoneInfo[1]); } catch(any expt){ variables.objZoneDAO = CreateObject("component", "#application.sComponentDir#ZoneDAO").init(application.sDSN); variables.objZoneDAO.Read(variables.objZone, 1); } </cfscript>. This only tends to happen for the occasional bots. The XML file is there and works for all users. Any ideas? - pee2pee

3 Answers

1
votes

1) You use two different coding styles

    <cfparam name="url.refresh" default="0">
    <cfset request.strMember = Duplicate(session.strMember)/>

Invalid/left open XML tags in first line and valid (closed) XML tags in the second line. Try to stick to one (preferably the last one).

2) You are using old way of checking variable being defined

IsDefined("session.strMember.sRoles")

read about newer (and better and faster)

StructKeyExists(session.strMember, "sRoles")

3) Most likely your code is calling

<cfloginuser ... >

at every page request

4) Make sure that paths for all includes are correct and they themselves don't have any errors.

Simplify your method until you stop getting an error and then investigate what exactly is causing it

0
votes

Are the bots hitting a page that doesn't exist?

Maybe try changing the last line to:

<cfif fileExists(expandPath(Arguments.targetPage))>
    <cfinclude template="#Arguments.targetPage#">
<cfelse>
    <cfabort>
</cfif>
0
votes

Maybe you could detect if they are a bot and server them something else? depends on how search friendly you want your site to be:

http://www.bennadel.com/blog/1083-ColdFusion-Session-Management-And-Spiders-Bots.htm