Skip to main content
Inspiring
May 26, 2010
Question

Getting an odd error, please help!

  • May 26, 2010
  • 3 replies
  • 4066 views

I've been getting these odd error messages pretty much since I've had CF 8 installed, but I cannot find any solutions!  I'm getting a Event handler exception error.  It doesn't seem to be my code, as this happens sometimes, but other times my app behaves like its supposed to!

Here is the error dump:

Error - struct

Cause

Error - struct

Message

[empty     string]

StackTrace

java.lang.NullPointerException

TagContext

Error - array [empty]

Type

java.lang.NullPointerException

Detail

An   exception occurred when invoking a event handler method from Application.cfc.   The method name is: onRequestStart.

Message

Event   handler exception.

RootCause

Error - struct

Message

[empty     string]

StackTrace

java.lang.NullPointerException

TagContext

Error - array [empty]

Type

java.lang.NullPointerException

StackTrace

coldfusion.runtime.EventHandlerException:   Event handler exception. at   coldfusion.runtime.AppEventInvoker.onRequestStart(AppEventInvoker.java:229)   at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:264) at   coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)   at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at   coldfusion.filter.PathFilter.invoke(PathFilter.java:86) at   coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at   coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)   at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at   coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at   coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at   coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at   coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:126)   at coldfusion.CfmServlet.service(CfmServlet.java:175) at   coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at   jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at   coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)   at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at   jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at   jrun.servlet.FilterChain.service(FilterChain.java:101) at   jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at   jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at   jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286) at   jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at   jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)   at   jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)   at   jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)   at   jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)   at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66) Caused by:   java.lang.NullPointerException

TagContext

Error - array [empty]

Type

Expression

name

onRequestStart

Any ideas on what is causing this error?

    This topic has been closed for replies.

    3 replies

    EnergyFedAuthor
    Inspiring
    May 28, 2010

    It might be too early to tell if the problem is solved or not, but I think it's fixed.

    CF wasn't expecting any variables to be pre-defined, so I know that wasn't the problem.  And I couldn't for the life of me figure out why I was getting the error even after playing with the timeouts.

    So I completely re-did my Application.cfc, after finding a slightly different template than what I was using.  I then moved my login process to it's own CFC and called it from the Application.cfc.  After I did that the initial problem went away, but was having problems with my session variables.  They would sometimes set, but other times would not.  I played with that for a while and think I've solved that too.

    Dan, one thing I did do that may help you troubleshoot your issue is to log every call to the OnRequestStart.  I used the code below to makes sure that OnRequestStart was actually firing.  The code I'm using now is more or less to test to make sure one of the sessions I've created is actually being set, but I'm sure you could do something similar to see what might be timing out.

    Thanks for your suggestions!

    -Chris

    <cfsavecontent variable="theRequest">
        <cfoutput>
            OnRequestStart - ThisUser: #session.ThisUser# - Time: #NOW()#
           
        </cfoutput>
    </cfsavecontent>

                <cffile
                                    action="APPEND"
                                    file="#ExpandPath( './sessionTest.txt' )#"
                                    output="#theRequest#"
                                    addnewline="true"
                                    />

    Inspiring
    May 27, 2010

    I was recently getting something like that.  It was caused by poor timeout handling on my part.  The session would time out but the current page would stay on the page.  Then the user would do something, but all the session variables were gone.

    EnergyFedAuthor
    Inspiring
    May 27, 2010

    Dan, this is good maybe! Or at least sending me in the right direction..

    What settings did you have to adjust in order to get the errors to stop?

    Inspiring
    May 27, 2010

    Is your code making assumptions about session variables existing which might not be the case?  EG: assuming a session variable exists which is not initialised in onSessionStart (or validated for existence in onRequestStart).

    --

    Adam

    Inspiring
    May 26, 2010

    The only thing that sticks out - and it doesn't stick out much - is the reference to client variables.  Are you setting any client variables in your onRequestStart()?  Is client variable storage configured properly?

    It might be an idea to take a brute force approach and stick a <cfabort> at the top of your onApplicationStart() method, and keep moving it down a line until the error crops up.  This might give you more of any idea of what's causing the problem.

    --

    Adam

    EnergyFedAuthor
    Inspiring
    May 26, 2010

    Adam, thanks for your reply.  I am setting client variables in my OnRequestStart.  However, I get this error even when I'm not setting variables.  It really is a freak error, as I get it a few times a day, but I can never replicate it.  Below is my OnRequestStart code, and it could be possible that I've set it up wrong?

    <cffunction name="OnRequestStart">
    <cfargument name = "thisRequest" required="true"/>
        <cfset Request.mydns1 = "mydatabase">
        <cfset Request.CurrentPage=GetFileFromPath(GetTemplatePath())>
        <!--- <cflogout> --->
    <cfif isDefined("url.action") and url.action eq "logout">
                <cflogout>
            <cfset onSessionEnd(SESSION) />       
            </cfif>
    <!---Here is the Login process--->
            <cflogin>
    <cfif isDefined("form.j_username") and isDefined("form.j_password")>
                    <cfif len(form.j_username) and len(form.j_password)>
    <cfset theSalt = 'saltword' />
    <cfset thePass = '#theSalt##FORM.j_password#' />               
                   
    <cfquery name="loginQuery" dataSource="#Request.mydns1#">
    SELECT *
    FROM users
    WHERE username = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.j_username#"> AND password = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Hash(thePass, 'MD5')#">
    </cfquery>
                <cfif loginQuery.RecordCount EQ 1>

    <cfset session.ThisUser = loginQuery.id />
    <!--- We set this session var cause we will need it later --->

       
    <cfloginuser name="#loginQuery.id#" password="#form.j_password#" roles="1">

    <!---begin Who’s Online section --->
    <cfparam name="session.whosOnFirst" default="">
    <!--- Test for existence of UserInfo and create if necessary  --->
    <cflock timeout="15" scope="APPLICATION" type="EXCLUSIVE">
    <cfif NOT isDefined("Application.UsersInfo")>
    <cfset Application.UsersInfo = StructNew()>
    </cfif>
    </cflock>
    <cfif isDefined('form.j_username')>
    <!--- create new user info for the struct --->
    <cflock name="#CreateUUID()#" timeout="15" type="EXCLUSIVE">
    <cfset user_cfid = Evaluate(CFID) & "," & form.j_username>
    <cfset user_time = Now()>
    </cflock>
    <!--- set a session id so we can use it to verify that this session is still active in application.cfm --->
    <cfset session.whosOnFirst = user_cfid>
    <cflock scope="APPLICATION" type="EXCLUSIVE" timeout="15">
    <!--- If the user does not exist in the struct, insert it --->
    <cfif NOT StructKeyExists(Application.UsersInfo, user_cfid)>
    <cfset temp = StructInsert(Application.UsersInfo, user_cfid, user_time)>
    </cfif>
    </cflock>
    </cfif>
    <!--- end Who’s Online section --->             

                        <cfelse>

                            <cfinclude template="login.cfm">
                            <cfabort>
                        </cfif>
                    <cfelse>

                        <cfinclude template="login.cfm">
                        <cfabort>
                    </cfif>
                <cfelse>  
                   
                    <cfinclude template="login.cfm">
                    <cfabort>
                </cfif>
            </cflogin>
    </cffunction>

    Inspiring
    May 26, 2010

    Nothing leaps off the page at me, although I'm intrigued by the named <cflock> that has a UUID for a name.  What's the point of that?  You're never ever going to have another bit of code using the same name, so... err... the lock won't actually lock anything.

    But this will be nothing to do with your problem.

    Is this only happening on a live environment, or can you run a load test on a dev environment and replicate it there?

    Could it be something to do with requests coming in for sessions that have timed out, and somehow that session-usage you have in there is misbehaving?  I admit to be clutching at straws.

    --

    Adam