Results 1 to 5 of 5

Thread: nullpointerexception after site idle

  1. #1
    Join Date
    Apr 2012

    nullpointerexception after site idle

    After weeks of research and little help from my webhost I thought I'd ask the coldfusion community.
    I'm a beginner developer so bear with me. I'll provide as much info as I can think of.

    I'm getting a nullpointerexception error on my site any time it sits idle for a few minutes(less than 5). If I refresh the page it works fine...until the site sits idle again. I've attached the relevant files (application.cfc and header.cfm).
    It happens when GetAuthUser() is called on line 12 of header.cfm.
    I've tried moving that query to onrequeststart in application.cfc and setting a session variable but then i get the same nullpointerexception there.

    Another point is that I have the same exact setup on my local developer server and the error does not occur. The only difference is the lack of ssl on my developer server.

    Also, if I remove the form at the bottom of the header, the error doesn't occur.

    I tried to remove all the irrelevant code from the header.cfm

    Thanks in advance.

    this.name = "TCPro_1_5";
    this.applicationTimeout = createTimeSpan(0,0,90,0);
    this.clientmanagement= "no";
    this.loginstorage = "session" ;
    this.sessionmanagement = "yes";
    this.sessiontimeout = createTimeSpan(0,0,60,0);
    this.setClientCookies = "yes";
    this.setDomainCookies = "no";
    this.scriptProtect = "all";

    <cffunction name="onApplicationStart" output="false">
    //set your app vars for the application
    application.dsn = "tcswfldata";
    application.sessions = 0;
    <!--- Test whether the DB is accessible by selecting some data. --->
    test query here
    <!--- If we get a database error, report an error to the user, log the
    error information, and do not start the application. --->
    <cfcatch type="database">
    catch code here
    <cflog file="#this.name#" type="Information" text="Application #this.name# Started">
    <cfreturn True>
    <cffunction name="onApplicationEnd" output="false">
    <cfargument name="applicationScope" required="true">
    <cflog file="#this.name#" type="Information" text="Application #this.name# Stopped">
    <cffunction name="onSessionStart" output="false">
    session.started = now();
    session.defaultFacility = 0;
    <cflock scope="application" timeout="5" type="Exclusive">
    <cfset application.sessions = application.sessions + 1>
    <cflog file="#this.name#" type="Information"
    text="Session #session.sessionid# started.">
    <cffunction name="onSessionEnd" output="false">
    <cfargument name = "sessionScope" required=true/>
    <cfargument name = "applicationScope" required=true/>
    <cfset var sessionLength = TimeFormat(Now() - sessionScope.started, "H:mm:ss")>
    <cflock name="AppLock" timeout="5" type="Exclusive">
    <cfset arguments.applicationScope.sessions = arguments.applicationScope.sessions - 1>
    <cflog file="#this.name#" type="Information"
    text="Session #arguments.sessionScope.sessionid# ended. Length: #sessionLength# Active sessions: #arguments.applicationScope.sessions#">
    <cffunction name="onRequestStart" access="public" output="true">
    <cfargument name="requestname" required=true/>


    <!--- Check for login here --->
    <cfif isDefined('form.j_username') and isDefined('form.j_password')>
    cflogin here
    <cfelseif isDefined('form.nd_GOEmailPword')>
    reset password code here
    <cfelseif isDefined('URL.emailPwd')>
    an include file here
    <cfelseif NOT isUserLoggedIn()>
    an include file here
    <cfif isUserLoggedIn()>
    <cfif not structKeyExists(session,'defaultFacility')>
    <cfset session.defaultFacility = 0 />
    <cfif structKeyExists(form,'sessionDefaultFacility')>
    <cfinvoke component="/tcswfl/TCPro/components.tcpro" method="UpdateDefaultFacility" returnvariable="qResult">
    <cfinvokeargument name="defaultFacility" value="#sessionDefaultFacility#">
    <cfset defaultFacility = 0 />
    <cfquery name="qGetDefaultFacility" datasource="#application.dsn#">
    ,fu.facility_id as default_facility_id
    FROM tblUsers u
    join tblFacility_User fu on u.ID = fu.user_id and fu.default_facility
    WHERE uName = <cfqueryparam value="#getauthuser()#" cfsqltype="cf_sql_varchar /">
    <cfif qGetDefaultFacility.recordCount>
    <cfset defaultFacility = qGetDefaultFacility.default_facility_id />
    <cfif session.defaultFacility neq defaultFacility>
    <cfset session.defaultFacility = defaultFacility />


    <cffunction name="onError" output="true">
    error handling here

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><head>
    <!---TITLE GOES HERE --->
    <!--- css and javascript links go here--->
    <cfif IsUserLoggedIn()>
    <cfquery name="qMYID" datasource="#application.dsn#">
    SELECT ID AS myID, CONCAT(firstName,' ',lastName) AS myName
    FROM tblUsers
    WHERE uName = <cfqueryparam value="#getauthuser()#" cfsqltype="cf_sql_varchar /">
    <cfquery name="qMyLocations" datasource="#application.dsn#">
    SELECT fu.facility_id
    , fu.default_facility AS defFacility
    , f.location
    , f.description
    , concat(f.location, ' ( ', f.description, ' )') as location_display_name
    FROM tblFacility_User fu
    join tblUsers u on fu.user_id = u.ID
    join tblFacility f on fu.facility_id = f.ID
    WHERE u.ID = <cfqueryparam value="#qMYID.myID#" cfsqltype="cf_sql_integer" />
    <cfset utcTime = DateConvert('local2UTC',now())>
    <cfinvoke component="components.timezone" method="castFromUTC" returnvariable="localTime">
    <cfinvokeargument name="thisDate" value="#utcTime#">
    <cfinvokeargument name="thisTZ" value="#qLocalTZ.localTZ#">
    <cfif getAuthUser() NEQ ''>
    <div id="contatiner">
    <!---site logo goes here --->
    <div id="panel">
    <cfquery name="qFirstName" datasource="#application.dsn#">
    SELECT firstName
    FROM tblUsers
    WHERE uName = '#GetAuthUser()#'
    <div class="panel_content">
    <table width="100%">
    <td style="text-align:right">Welcome Back <cfoutput query="qFirstName"><strong>#firstName#</strong>
    </cfoutput><a href="/tcswfl/TCPro/settings.cfm">(Settings)</a>
    <!--- Navigation goes here --->
    <div id="header_content">
    <div id="panel2">
    <cfif qMyLocations.recordCount gt 1>
    <td style="vertical-align:top"><span class="smallText">current facility:&nbsp;</span></td>
    <form action="/tcswfl/TCPro/index.cfm" method="post" name="formSelectLocation">
    <select name="sessionDefaultFacility" onchange="submit();" style="font-size:10px;">
    <cfoutput query="qMyLocations">
    <option value="#qMyLocations.facility_id#"<cfif qMyLocations.facility_id EQ session.defaultFacility>selected=selected</cfif>>#qMyLocations.location_display_name#</option>
    <cfelseif qMyLocations.recordCount eq 1>
    <td><span class="smallText">Current Location: #qMyLocations.location_display_name#</span></td>

  2. #2
    Join Date
    Dec 2002
    St. Louis, MO, USA
    I've looked and looked at the code, and the only thing that I can think of is that the CF 9 server isn't properly set up for using GetAuthUser(). OR, something else may be interfering with it.
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long


  3. #3
    Join Date
    Apr 2012
    Many thanks for checking it out. I've just uploaded the site to a different host and the problem isn't there. I can't seem to convince my current host that "it's you and not me". Guess its about time to change.

    Thanks again

  4. #4
    Join Date
    Apr 2012
    just wanted to follow up with this in case anyone else has a similar issue. I contacted my web host and explained the problem. they disabled the "maintain connections" options in the datasource options of the coldfusion server and now everything works fine with no errors. there's a good explanation of the issue here: http://forums.adobe.com/message/3396333

    hope this helps someone

  5. #5
    Join Date
    Dec 2002
    St. Louis, MO, USA
    Glad that you got it working. AND that it wasn't your code. I thought it all seemed correct. Did they apologize for not believing you?
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.10429 seconds
  • Memory Usage 2,918KB
  • Queries Executed 15 (?)
More Information
Template Usage (32):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (5)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates