I just did an upgrade to a system a couple days ago from CF7 to CF8. I received a report from users that a section of the system that generates pdf reports was breaking. I found this strange since this section of the system is used daily and we have not touched the code in over a year. I figured at this point that the upgrade had something to do with it. After some investigating I was able to figure out that it was in fact a CF8 specific issue. The code for the pdf generation worked in CF7 but breaks in CF8.
This is the error we were getting. The error itself it kinda odd because the code it shows does not contain the undefined var displayed in the error.
2The cause of this exception was that: coldfusion.document.spi.DocumentExportException: java.lang.RuntimeException: Variable ID is undefined..
3
4The error occurred in E:\www\code\report\index.cfm: line 735
5Called from E:\www\code\report\index.cfm: line 47
6Called from E:\www\code\report\index.cfm: line 735
7Called from E:\www\code\report\index.cfm: line 47
8
9733 : </TR>
10734 : <TR HEIGHT="14">
11735 : <TD ALIGN="CENTER"><BR><IMG SRC="http://localhost/images/samples/#DIAGRAM2#"></TD>
12736 : </TR>
13737 : </CFIF>
Here is the code that was causing the error. This is not the exact code as I can not post it but it still has the necessary parts to effectively display the issue.
2
3<CFOUTPUT QUERY="items">
4
5<CFDOCUMENTITEM TYPE="FOOTER">
6<table align="CENTER" width="100%" border="0" cellpadding="0" cellspacing="0">
7 <tr height="4">
8 <td height="4" colspan="3" bgcolor="F2F2F2"></td>
9 </tr>
10 <tr>
11 <td align="left" width="10%"><font size="-3" >#dateFormat(now(), "mm/dd/yyyy")#</font></td>
12 <td align="CENTER" width="80%"><font size="-3" >Project: (#id#) #title#</font></td>
13 <td align="right" width="10%"><font size="-3" >Page #cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</font></td>
14 </tr>
15 <tr height="4">
16 <td height="4" colspan="3" bgcolor="F2F2F2"></td>
17 </tr>
18</table>
19</CFDOCUMENTITEM>
20<!--- BODY OMITTED --->
21</CFOUTPUT>
22
23</CFDOCUMENT>
The actual error was coming from this line of code:
I could not quite understand why this would cause an error. I verified, via cfdump, that the data was coming out of the query accurately. Also, since I had a query attribute on the cfoutput the vars did not need to be scoped with the query name.
So, taking a shot in the dark I added the query name to the id and title vars. This fixed the issue and the pdf was generated.
I did even more digging after that and discovered that I only needed to scope them with the query name when inside cfdocumentitem. I was able to output the data just fine in the body unscoped.
Here is what the fixed code looks like. Just something else to look out for when doing an upgrade.
till next time,
--Dave
#1 by david buhler on 1/11/08 - 9:36 AM
#2 by Dave Ferguson on 1/11/08 - 10:04 AM
--Dave
#3 by Roy Arnold on 1/30/08 - 7:13 AM
When I try to check the cfdocument.currentpagenumber reserved variable,
I get the ERROR:
"Element CURRENTPAGENUMBER is undefined in CFDOCUMENT. "
The code is outside of any cfdocumentitem tag, but within the main cfdocuent
tag where format="pdf". This has been working until CF8...TIA...
#4 by Chris Herdt on 2/19/08 - 11:48 AM
Once I set a variable in the VARIABLES scope just before the CFDOCUMENTITEM tag and referred to that, it worked fine.
#5 by Kris Jones on 3/27/08 - 10:54 AM
coldfusion.document.spi.DocumentExportException:
java.lang.NullPointerException
prefacing the query items with the query name fixes the problem as Dave shows.
#6 by Chris on 6/2/08 - 6:49 AM
Within cfdocumentitem you can NOT use variables with a query name prefix. (Although you should always prefix your variables.) Plus, if inside a CFC method, you can not use local variables inside cfdocumentitem. :-(
Chris
#7 by patrick on 7/7/08 - 11:48 AM
#8 by Rob O on 7/15/08 - 11:15 AM
That's just stupid.
So, from what I've gathered, you cannot use Query, Arguments, or Session scopes within CFDOCUMENT (that is, in CF8 - this all worked in CF7). Although I haven't tested, I'd be willing to say that anything outside of the VARIABLES scope would thrown an error.
Enjoy.
#9 by crab on 12/14/08 - 9:10 PM
This helps me fix my broken TABLE problem in CF8 PDF