We help IT Professionals succeed at work.

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

binarybilly
binarybilly asked
on
Medium Priority
1,834 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> ---> ">
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
> 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 ?

Author

Commented:
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)

Author

Commented:
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

Author

Commented:
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

CERTIFIED EXPERT

Commented:

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

CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
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
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:

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

CERTIFIED EXPERT
Most Valuable Expert 2015
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
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?
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
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#
CERTIFIED EXPERT

Commented:

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


Author

Commented:
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.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.