Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

In Agony - OnSessionEnd Error

Guest
Apr 28, 2006 Apr 28, 2006
I have my app up and running and never got this while testing, so I'm assuming it may be a robot or search engines.

cferror is working fine and it sends me dumps of the error scopes. Here is the problem, I'm getting an email after email saying that

Detail: An exception occurred when invoking a event handler method from Application.cfc The method name is: onSessionEnd.
Message: Event Handler Exception.
RootCause: struct
Message: [empty string]
Type: java.lang.NullPointerException


My onSessionEnd looks like this:
<cffunction name="onSessionEnd">
<cfargument name = "SessionScope" required=true/>
<cfargument name="ApScope" required="true"/>
</cffunction>

Please help!
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 30, 2006 Apr 30, 2006
Possibly caused by the cflocation-cferror bug. Here's Christian Cantrell's workaround. You have to put the following code in cferror.

<cfif arguments.exception.rootCause eq "coldfusion.runtime.AbortException">
<cfreturn />
</cfif>




Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 01, 2006 May 01, 2006
I'm actually already using that fix. Thanks! It still gives me the error.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 01, 2006 May 01, 2006
You might have to change your cfError code, as suggested by some in the above reference. They seem to have faced problems with the key, rootCause. Experiment with



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 01, 2006 May 01, 2006
I appear not to be the only one with this problem: http://www.jeffryhouser.com/index.cfm/2006/1/31/OnError-and-OnSessionEnd

I've tried to manipulate this several times using different variations of Ray Camden's blog entries. However it seems that my type is always EXPRESSION. I'm really at a loss here. There is absolutely nothing in my onSessionEnd, so why is there an error?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2006 May 02, 2006
Yes, strange, indeed. Are application and session variables enabled in the Coldfusion Administrator? Do you have something like this just after the cfcomponent tag in Application.cfc

<cfset This.applicationTimeout="#CreateTimeSpan(1,0,0,0)#">
<cfset This.sessionmanagement="True">
<cfset This.sessiontimeout="#CreateTimeSpan(0,0,20,0)#">

The "rootCause" workaround is itself not perfect. For example, it instructs a void method, onError(), to return. What happens when you remove it altogether from onError? And when you put some dummy code in onSessionEnd, like this?

<cffunction name="onSessionEnd">
<cfargument name = "SessionScope" required=true />
<cfargument name="ApplicationScope" required=true />
<cfset test_var1 = Arguments.SessionScope.URLToken>
<cfset test_var2 = Arguments.ApplicationScope.name>
<cflog file="#This.Name#" text="session's URLToken= #test_var1#. Application's name= #test_var2#>
</cffunction>








Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 02, 2006 May 02, 2006
Yes, I have tried it all. Nothing works! I've even disabled cookies and tried to produce the error on my own by manually firing onSessionEnd and I get no error. I'm getting about 40 errors a minute all the same. There has got to be a reason!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2006 May 02, 2006
Yes, I have tried it all. Nothing works! I've even disabled cookies and tried to produce the error on my own by manually firing onSessionEnd and I get no error. I'm getting about 40 errors a minute all the same. There has got to be a reason!

Time to roll back the sleeves. Put the code

<!--- get a clone of the entire session structure--->
<cfset application.sessions=structnew()>
<cfset application.sessions=duplicate(session)>

at the beginning of onSessionStart, and put

<!--- dump session structure to the logs as sessionDump.log--->
<cfsavecontent variable="sessionDump">
<cfloop collection="#application.sessions#" item="sessionKey">
<cfoutput>#application.sessions[sessionKey]#; </cfoutput>
</cfloop>
</cfsavecontent>
<cflog file="sessionDump" text="Dump of session structure:#sessionDump#">

at the bottom of onError.

It is to answer the question whether or not there is a session. Perhaps the structure is deleted right after you create it. However, since sessions have something to do with the exception, you cannot use that scope within onError, hence my use of the application scope. Now, what does the log file show?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 02, 2006 May 02, 2006
quote:



Time to roll back the sleeves. Put the code

<!--- get a clone of the entire session structure--->
<cfset application.sessions=structnew()>
<cfset application.sessions=duplicate(session)>
I did this but session was not defined. It is my understanding that session was not defined in onSessionEnd so I did change this to arguments.sessionScope and received the error Message.
Detail ColdFusion does not support making a copy of a ColdFusion Component.
ErrNumber 0
Message Unable to duplicate a ColdFusion Component.



The code below seems to work fine
<!--- dump session structure to the logs as sessionDump.log--->
<cfsavecontent variable="sessionDump">
<cfloop collection="#application.sessions#" item="sessionKey">
<cfoutput>#application.sessions[sessionKey]#; </cfoutput>
</cfloop>
</cfsavecontent>
<cflog file="sessionDump" text="Dump of session structure:#sessionDump#">

at the bottom of onError.




I'm really stuck here.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2006 May 02, 2006
My question again. What do you get in the log file when you put the first code block at the beginning of onSessionStart and the second block at the end of onError?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 02, 2006 May 02, 2006
I just go the standard not defined error. I don't have the dump right now as I'm home. I'm not using logs, I'm using a dump sent by cfmail to my admin account.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2006 May 02, 2006
If the log file does not show session variables, it will mean that coldfusion is either not creating the session structure (unlikely) or some process is deleting the session structure soon after coldfusion creates it. Do you anywhere apply structclear() or structdelete() to session?



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 03, 2006 May 03, 2006
BKBK - Thanks so much for your continued support.

Here is where the only structclear is -

<cfif isdefined('url.logout')>
<cfset StructDelete(session, "shoppingCart","no")>
<cfset StructDelete(session, "user","no")>
<cfset onSessionStart()>
</cfif>

Now, with the above code, onSessionStart recreates the shoppingcart and user in the session struct. The thing is, this logout link is only shown if a user is logged in, which is 4 or 5 people at the same time according to my data. (most of our users have no need to login). This doesn't account for the 40 errors every minute or two. Nowehere in my code do I destroy the entire session.

I also set the cookies manually and am using <cfset this.setclientcookies="no">.

Let's think about how a search engine behaves. It is a user with no cookies therefore, each page visit would cause the session to end, correct? How would coldfusion track this?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 03, 2006 May 03, 2006
On a more positive note, this appears to be the only time I've gotten an error, so my app is running rather smoothly other than this.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2006 May 03, 2006
LATEST
On an incidental note, I don't think there is any need to make the call <cfset onSessionStart()>. In fact, it is rarely necessary to manually call any of the functions in Application.cfc. When you do so, strange errors sometimes result. That is so because they are not merely functions, but event-handlers. For example, it cannot be a good thing to manually call the function while it continues to lock a thread that started when the event last fired.



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources