binarybilly
asked on
Coldfusion Error - Null Pointers are another name for undefined values.
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
Every once in a while this error will show up on the page.
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>#GetSpe cial.title #</p> <!--- <p class='clickhere'>(Click here from more details.)</p> ---> ">
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 -->
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/httpdoc s/Applicat ion.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()
<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
ASKER
1) yes, we are using MySQL.
2)
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/httpdoc s/Applicat ion.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.JRunState ment.setMa xRows(JRun Statement. java:214)
at coldfusion.sql.Executive.executeQuer y(Executiv e.java:127 6)
at coldfusion.sql.Executive.executeQuer y(Executiv e.java:100 8)
at coldfusion.sql.Executive.executeQuer y(Executiv e.java:939 )
at coldfusion.sql.SqlImpl.execute(SqlIm pl.java:32 5)
at coldfusion.tagext.sql.QueryTag.execu teQuery(Qu eryTag.jav a:831)
at coldfusion.tagext.sql.QueryTag.doEnd Tag(QueryT ag.java:52 1)
at cfApplication2ecfm1047282108.runPage (/var/www/ vhosts/myd omain.com/ httpdocs/A pplication .cfm:7)
at coldfusion.runtime.CfJspPage.invoke( CfJspPage. java:196)
at coldfusion.tagext.lang.IncludeTag.do StartTag(I ncludeTag. java:370)
at coldfusion.filter.CfincludeFilter.in voke(Cfinc ludeFilter .java:65)
at coldfusion.filter.CfincludeFilter.in clude(Cfin cludeFilte r.java:33)
at coldfusion.filter.ApplicationFilter. invoke(App licationFi lter.java: 214)
at coldfusion.filter.RequestMonitorFilt er.invoke( RequestMon itorFilter .java:48)
at coldfusion.filter.MonitoringFilter.i nvoke(Moni toringFilt er.java:40 )
at coldfusion.filter.PathFilter.invoke( PathFilter .java:86)
at coldfusion.filter.ExceptionFilter.in voke(Excep tionFilter .java:70)
at coldfusion.filter.ClientScopePersist enceFilter .invoke(Cl ientScopeP ersistence Filter.jav a:28)
at coldfusion.filter.BrowserFilter.invo ke(Browser Filter.jav a:38)
at coldfusion.filter.NoCacheFilter.invo ke(NoCache Filter.jav a:46)
at coldfusion.filter.GlobalsFilter.invo ke(Globals Filter.jav a:38)
at coldfusion.filter.DatasourceFilter.i nvoke(Data sourceFilt er.java:22 )
at coldfusion.CfmServlet.service(CfmSer vlet.java: 175)
at coldfusion.bootstrap.BootstrapServle t.service( BootstrapS ervlet.jav a:89)
at jrun.servlet.FilterChain.doFilter(Fi lterChain. java:86)
at coldfusion.monitor.event.MonitoringS ervletFilt er.doFilte r(Monitori ngServletF ilter.java :42)
at coldfusion.bootstrap.BootstrapFilter .doFilter( BootstrapF ilter.java :46)
at jrun.servlet.FilterChain.doFilter(Fi lterChain. java:94)
at jrun.servlet.FilterChain.service(Fil terChain.j ava:101)
at jrun.servlet.ServletInvoker.invoke(S ervletInvo ker.java:1 06)
at jrun.servlet.JRunInvokerChain.invoke Next(JRunI nvokerChai n.java:42)
at jrun.servlet.JRunRequestDispatcher.i nvoke(JRun RequestDis patcher.ja va:286)
at jrun.servlet.ServletEngineService.di spatch(Ser vletEngine Service.ja va:543)
at jrun.servlet.jrpp.JRunProxyService.i nvokeRunna ble(JRunPr oxyService .java:203)
at jrunx.scheduler.ThreadPool$Downstrea mMetrics.i nvokeRunna ble(Thread Pool.java: 320)
at jrunx.scheduler.ThreadPool$ThreadThr ottle.invo keRunnable (ThreadPoo l.java:428 )
at jrunx.scheduler.ThreadPool$UpstreamM etrics.inv okeRunnabl e(ThreadPo ol.java:26 6)
at jrunx.scheduler.WorkerThread.run(Wor kerThread. java:66)
ASKER
Also, which log files should I be looking at?
I did find this:
I did find this:
'' The specific sequence of files included or processed is: /var/www/vhosts/mydomain.com/httpdoc s/index.cf m, line: 7
ASKER
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>
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
java.lang.NullPointerExcep tion
at com.mysql.jdbc.Statement.s etMaxRows( Statement. java:2178)
at coldfusion.server.j2ee.sql .JRunState ment.setMa xRows(JRun Statement. java:214)
at com.mysql.jdbc.Statement.s etMaxRows( 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
at com.mysql.jdbc.Statement.s
at coldfusion.server.j2ee.sql
at com.mysql.jdbc.Statement.s
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oh ya, deja vu... I seem to recall a previous issue agx fixed with that solution...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
Am I changing the cfparam or the variable in the query?
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#
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#
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
ASKER
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.
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 ?