Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Coldfusion Error - Null Pointers are another name for undefined values.

Posted on 2011-04-26
13
Medium Priority
?
1,554 Views
Last Modified: 2012-05-11
Okay, here is the problem as I see it. The main index file calls up cfparam "specialBanner" from another page called "application.cfm", but it is not linked nor is that page referenced in the code.

On that page the cfparam "specialBanner" is then cfset to a string. Sometimes it works, sometimes it does not. Can anyone help me?

See errors and code below:



the main index.cfm calls a cfparam defined on another page as "specialBanner"

index.cfm
 <!-- Special Content Start -->
 <div id="special-banner-wrapper">
 <div  id="special-banner">
 <a href="special/index.cfm"><cfoutput>#specialBanner#</cfoutput></a></div >
 </div >
 <!-- Special Content End -->

Open in new window


Every once in a while this error will show up on the page.

the system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.Null Pointers are another name for undefined values.
 The error occurred in /var/www/vhosts/mydomain.com/httpdocs/Application.cfm: line 7
5 : <CFPARAM NAME="month" default="">
6 :
7 : <cfquery name="GetSpecial" datasource="TestDB">
8 : SELECT TITLE,MONTH,BODY FROM SPECIAL WHERE SPECIAL_ID=1
9 : </cfquery>



The specialBanner param is defined on the applicaiton.cfm page like this:

<CFPARAM NAME="YEAR" default="#DATEFORMAT(now(),'YYYY')#">
<CFPARAM NAME="specialBanner" default="">
<CFPARAM NAME="title" default="">
<CFPARAM NAME="body" default="">
<CFPARAM NAME="month" default="">

<cfquery name="GetSpecial" datasource="TestDB">
SELECT TITLE,MONTH,BODY FROM SPECIAL WHERE SPECIAL_ID=1
</cfquery>

<cfset specialBanner = "<strong>#GetSpecial.month# Special</strong><p>#GetSpecial.title#</p> <!--- <p class='clickhere'>(Click here from more details.)</p> ---> ">
0
Comment
Question by:binarybilly
  • 5
  • 4
  • 4
13 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 35468045
> The error occurred in /var/www/vhosts/mydomain.com/httpdocs/Application.cfm: line 7

Error line numbers are approximate only. But it sounds more like your error is caused by the query.
1)  Any chance you're using MySQL?
2) There should be more error detail in your log files. What's the rest of the error message above ?
0
 

Author Comment

by:binarybilly
ID: 35468113
1) yes, we are using MySQL.
2)
The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.Null Pointers are another name for undefined values.
 The error occurred in /var/www/vhosts/mydomain.com/httpdocs/Application.cfm: line 7
5 : <CFPARAM NAME="month" default="">
6 :
7 : <cfquery name="GetSpecial" datasource="TestDB">
8 : SELECT TITLE,MONTH,BODY FROM SPECIAL WHERE SPECIAL_ID=1
9 : </cfquery>

Resources:
      * Check the ColdFusion documentation to verify that you are using the correct syntax.
      * Search the Knowledge Base to find a solution to your problem.




java.lang.NullPointerException
        at com.mysql.jdbc.Statement.setMaxRows(Statement.java:2178)
        at coldfusion.server.j2ee.sql.JRunStatement.setMaxRows(JRunStatement.java:214)
        at coldfusion.sql.Executive.executeQuery(Executive.java:1276)
        at coldfusion.sql.Executive.executeQuery(Executive.java:1008)
        at coldfusion.sql.Executive.executeQuery(Executive.java:939)
        at coldfusion.sql.SqlImpl.execute(SqlImpl.java:325)
        at coldfusion.tagext.sql.QueryTag.executeQuery(QueryTag.java:831)
        at coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:521)
        at cfApplication2ecfm1047282108.runPage(/var/www/vhosts/mydomain.com/httpdocs/Application.cfm:7)
        at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196)
        at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370)
        at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
        at coldfusion.filter.CfincludeFilter.include(CfincludeFilter.java:33)
        at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:214)
        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.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)

0
 

Author Comment

by:binarybilly
ID: 35468157
Also, which log files should I be looking at?

I did find this:

'' The specific sequence of files included or processed is: /var/www/vhosts/mydomain.com/httpdocs/index.cfm, line: 7
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 

Author Comment

by:binarybilly
ID: 35468349
This is the complete code from the Application.cfm page.

<CFPARAM NAME="YEAR" default="#DATEFORMAT(now(),'YYYY')#">
<CFPARAM NAME="specialBanner" default="">
<CFPARAM NAME="title" default="">
<CFPARAM NAME="body" default="">
<CFPARAM NAME="month" default="">

<cfquery name="GetSpecial" datasource="TestDB">
SELECT TITLE,MONTH,BODY FROM SPECIAL WHERE SPECIAL_ID=1
</cfquery>

<cfset specialBanner = "<strong>#GetSpecial.month# Special</strong><p>#GetSpecial.title#</p> <!--- <p class='clickhere'>(Click here from more details.)</p> ---> ">


<CFAPPLICATION NAME="TestDB" CLIENTMANAGEMENT="YES" SESSIONMANAGEMENT="YES">

<cfquery datasource="TestDB" name="getParams">
SELECT * FROM PARAMS
</cfquery>

<cfset db = "#getParams.db#">
<cfset password = "#getParams.password#">

<cflock scope="SESSION" type="EXCLUSIVE" timeout="10">
  <cfparam name="session.pass" default = "">
</cflock>

Open in new window

0
 
LVL 39

Expert Comment

by:gdemaria
ID: 35468408

This error can be misleading, it's different from "a variable is not defined" although it sounds like it.

Most commonly (but not always) it is because you're using a variable with no value in a function that requires a date

For example...

<cfset today = "">
<cfset DateFormat(today, "mm/dd/yyyy")>

Today is blank so Date Format doesn't know what to do with it..

Check for your values passed to any date functions to make sure they are not blank

0
 
LVL 52

Expert Comment

by:_agx_
ID: 35468476
java.lang.NullPointerException
        at com.mysql.jdbc.Statement.setMaxRows(Statement.java:2178)
        at coldfusion.server.j2ee.sql.JRunStatement.setMaxRows(JRunStatement.java:214)
        at com.mysql.jdbc.Statement.setMaxRows(Statement.java:2178)
 

Yeah, I'm pretty sure that's an old issue w/MySQL that's been around for a while. AFAIK the best fix is to add a validation query like "Select 1" to the datasource:
http://forums.adobe.com/message/3396302#3396302
0
 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 1000 total points
ID: 35468493
i am curious about this

<CFPARAM NAME="month" default="">

You have a variable in the query also called month and month is also a built in function name.

I suggest changing the value of this variable.   I usually call variables that conflict with a functions or reserved words using the word "the" as in ... . "theMonth" or "theYear" , "theDate"   it keeps it from conflicting...

0
 
LVL 39

Expert Comment

by:gdemaria
ID: 35468507

oh ya, deja vu...   I seem to recall a previous issue agx fixed with that solution...

0
 
LVL 52

Accepted Solution

by:
_agx_ earned 1000 total points
ID: 35468559
month is also a built in function name

Ditto to changing the variable name.

oh ya, deja vu...   I seem to recall a previous issue agx fixed with that solution...

Yeah, it's kind of annoying since it's been around since vCF8.  But at least the work around is relatively painless :)

Btw: To add a validation query, log into CF Administrator

- Select "Data & Services" > "Datasources" > (Edit your datasource)
- Click Advanced Settings. In the "Validation Query" box enter:
SELECT 1

Open in new window

- Save the settings
0
 

Author Comment

by:binarybilly
ID: 35468788
Okay, so I've added the "SELECT 1" validation Query. But I'm a little confused on changing the "month" to "theMonth".

Am I changing the cfparam or the variable in the query?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 35468879
Am I changing the cfparam or the variable in the query?

That part's optional btw.  But you'd change the cfparam and anywhere you use that #month# variable.  The query variable is ok as is because it's scoped.  
            ie #queryName.month# not just #month#
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 35469021

Ok, I just tested it.   The Coldfusion built in functions do NOT conflict with the variables with the same name.  It is the custom function which exist in the variable scope and cannot be named the same as a variable.

This test works..

    <cfset month = now()>
    <cfset month = month(month)>
    <cfoutput> the month is #month#</cfoutput>

So you can ignore my comment about changing the name of Month to theMonth.  Although I feel it is still good practice and your code is confusing and prone to bugs because you have a variable "month" and one in the query "getSpecial.month"  

You should scope your variables..


variables.month

   and

getSpecial.month


0
 

Author Comment

by:binarybilly
ID: 35469023
wow, looks like everything is fixed. You guys are great. I've got more sites with problems. I will posting on them later. Thanks again.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question