• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFHTMLTOPDF Fails Under 2021/Update 5 After Upgrading Java to 11.0.17

Explorer ,
Oct 25, 2022 Oct 25, 2022

Copy link to clipboard

Copied

CF Version: 2021,0,05,330109

Java Version: 11.0.17

 

This is the same error I reported last year here, but the solution of changing the order the services are started in no longer works. The issue actually returned after upgrading Java and not necessarily after the move to 2021/5. However, the release notes for 2021/5 mention several bug fixes related to PDF generation, so I have to wonder if one of these is to blame.

 

Here are the last 2 lines in the CF server log after starting the services:

 

"Error","Thread-33","10/24/22","15:39:58","","Read timed out 127.0.0.1:8993/PDFgServlet/"
"Error","ajp-nio-127.0.0.1-8020-exec-2","10/24/22","16:02:17","","Registration error for service manager : .127.0.0.1:8993/PDFgServlet/.Reason: SERVER ERROR"

 

We also noticed this in the PDF logs - the first entry was under Java 11.0.16.1 and was successful:

 

127.0.0.1 - - [24/Oct/2022:13:39:38 +0000] "POST /PDFgServlet/ HTTP/1.1" 200 22100 "-" "Apache-HttpClient/4.5.13 (Java/11.0.16.1)"

127.0.0.1 - - [24/Oct/2022:16:03:11 +0000] "POST /PDFgServlet/ HTTP/1.1" 500 489 "-" "Apache-HttpClient/4.5.13 (Java/11.0.17)"

 

Thoughts?

 

Thanks,

Eric

TOPICS
Reporting , Server administration

Views

833

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Nov 15, 2022 Nov 15, 2022

We did some more testing and the only way CFHTMLTOPDF will work for us under Java 11.0.17 is if we point CF to Java 11.0.17 and the jetty config variable (ax.nl.current.vm) to the VM under the CF21 directory - i.e., [server root]\ColdFusion2021\jre\bin\javaw.exe, which is currently 11.0.1. 

 

We are going to leave it at that.

 

Thanks for everyone's help with this,

-Eric

Votes

Translate

Translate
Community Expert ,
Oct 25, 2022 Oct 25, 2022

Copy link to clipboard

Copied

Could you please share a sample of the code causing the error?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 25, 2022 Oct 25, 2022

Copy link to clipboard

Copied

@BKBK 

 

Even the simplest example causes the error:

 

<cfhtmltopdf><h1>test</h1></cfhtmltopdf>

 

The error and stack trace are also similar to the error we reported last year:

 

Error occurred while generating PDF.

Reason: SERVER ERROR

 

coldfusion.document.webkit.PDFgErrorHandler$ServiceManagerConversionException: Error occurred while generating PDF.
	at coldfusion.document.webkit.PDFgErrorHandler.handleConversionError(PDFgErrorHandler.java:190)
	at coldfusion.document.webkit.HttpPDFRequestHandler.requestPDFGeneration(HttpPDFRequestHandler.java:178)
	at coldfusion.tagext.htmltopdf.HtmlToPdfTag.processPDFgRequest(HtmlToPdfTag.java:1149)
	at coldfusion.tagext.htmltopdf.HtmlToPdfTag.handlePDFgConversionRequest(HtmlToPdfTag.java:1301)
	at coldfusion.tagext.htmltopdf.HtmlToPdfTag.convertToPDF(HtmlToPdfTag.java:1236)
	at coldfusion.tagext.htmltopdf.HtmlToPdfTag.doEndTag(HtmlToPdfTag.java:1414)

 

In the CF Admin, the PDF service validates (see attached).

 

-Eric

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 25, 2022 Oct 25, 2022

Copy link to clipboard

Copied

Have you also upgraded the JDK in Add-On service or just ColdFusion? I tried CF2021 update 5 and JDK11.0.17 and I am able to generate the PDFs. 

Thanks,
Priyank Shrivastava

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

@ej401 ,

Following Priyank, I too have run your sample code, without any problem. (I didn't have to re-install the Add-On service.) This suggests we can rule out Update 5 of CF 2021 as the cause. This is further confirmed by the fact that your PDF connection test in the Administrator was successful.

 

The error occurred during the conversion from CFM to PDF. That much is clear from the error message:

coldfusion.document.webkit.PDFgErrorHandler.handleConversionError(PDFgErrorHandler.java:190)
	at coldfusion.document.webkit.HttpPDFRequestHandler.requestPDFGeneration(HttpPDFRequestHandler.java:178)

 

This gets me thinking that there might be something in your system that is interferring with HTML representation. Or perhaps with character encoding in general. 

 

Have a look at /bin/jvm.config. Do you use any JVM flags that might affect HTML? Does java.args include the flag -Dfile.encoding=UTF8 ? It should. If you were to edit jvm.config, remember to restart ColdFusion.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

If after all of the above it still errors, then do a review as follows:

  1. Go to the PDF Service page in the Administrator. Verify the PDF service as you had done previously ("OK"). 
        Ensure the service is enabled. (What I usually do is click on the Disable button, then on the Enable button.)
    BKBK_0-1666780107182.png
  2.  Restart ColdFusion.
  3.  Have a look at server.log. Ensure that it contains a log similar to '"Information","Thread-25","10/26/22","12:05:38","","PDFg service manager http://127.0.0.1:8993/PDFgServlet/ registered."'
  4.  Reopen the PDF Service page in the Administrator. Confirm - just by looking - that the Enable button is still active.
  5.  Launch the test CFM page (containing the cfhtmltopdf code). What is the result?
  6.  Still an error? Then remove the h1 html tags and try again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

@BKBK @Priyank Shrivastava. 

 

Thanks for all of the tips guys. Ultimately, we found that the Java version specified in the jetty config file was the issue: ColdFusion2021\cfusion\jetty\jetty.lax (LAX.NL.CURRENT.VM setting).

 

When we changed the jdk reference from 11.0.17 back to 11.0.16 and restarted the services, the pdf conversion started to work again. The PDFgServlet "registered" line was also added to the CF server log after our first conversion attempt (which has always been the case for us - it was never added automatically just from a server restart).

 

When you all tested with Java 11.0.17, are you sure that the jetty config file was not still pointing to 11.0.16? We are now looking to see if the version of jetty CF2021 is using is compatible with Java 11.0.17.

 

Thanks,

Eric

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

Hi Eric,

I have to verify this scenario but it should work because currently my JDK is upgraded in CF but not in Jetty. That is what I asked in my response earlier if you made changes to Jetty JDK or only for CF. If it is working for you then no need to worry about it and you can use JDK11.0.17 with Jetty.

 

Thanks,
Priyank Shrivastava

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

@ej401 , in answer to your questions:

  1. I did verify - in the ColdFusion Administrator - that CF 2021 Update 5 is indeed using Java 11.0.17. That's the very first thing I do after installing Java.
  2.  LAX.NL.CURRENT.VM setting (in ColdFusion2021\cfusion\jetty\jetty.lax): C:\\ColdFusion2021\\jre\\bin\\javaw.exe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

New idea: 

in the Environment Variables of the Operation system,

  1. create a JAVA_HOME variable and set its value to the full-path of the jdk-11.0.17 directory;
  2. add the/full/path/to/jdk-11.0.17/bin to the PATH Environment Variable.

 

How I arrived at that idea:

Following in the footsteps of the article [ https://support.oneidentity.com/kb/4293805/how-to-check-which-jetty-configuration-is-being-used-by-m... ], I ran a CFM page containing the code

<cfexecute name = "C:\Program Files\Java\jdk-11.0.17\bin\java.exe" 
    arguments = " -jar C:/ColdFusion2021/cfusion/jetty/start.jar --list-config" 
    outputFile = "C:\Temp\output.txt" 
    timeout = "10"> 
</cfexecute>

 

The resulting output suggests that ColdFusion's Jetty might be using JAVA_HOME by default.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

@BKBK 

 

When you have time, could you "humor me" and instead of pointing your jetty.lax file setting to the JRE directory under ColdFusion21, point it to the full JDK 11.0.17 path? After that, restart all services and re-test.

 

I'm not sure we're comparing apples to apples here.

 

@Priyank Shrivastava. 

 

You said your JDK is updated in CF, but not in Jetty. I think that is the point I'm trying to get across - we have the issue when both CF and jetty are configured for Java 11.0.17.

 

Thanks,

Eric

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

quote

@BKBK 

 

When you have time, could you "humor me" and instead of pointing your jetty.lax file setting to the JRE directory under ColdFusion21, point it to the full JDK 11.0.17 path? After that, restart all services and re-test.

 

 

By @ej401

 

No problem.

Here is what I have done:

1. Change the JVM setting in jetty.lax so that it points to C:\Program Files\Java\jdk-11.0.17\bin\javaw.exe

BKBK_0-1666814162740.png

 

2. Restart each service: .NET, Add-On, ColdFusion Server, ODBC Agent, ODBC Server.

3. Launch a CFM page containing the following code:

<cfhtmltopdf>

<h1>test</h1>

<p><h2>ColdFusion Java version: <cfoutput>#server.system.properties.java.runtime.version#</cfoutput></h2> </p>

</cfhtmltopdf>

The result is the attached PDF.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 26, 2022 Oct 26, 2022

Copy link to clipboard

Copied

I hope that that convinces you we are both talking apples. Could you now check out the new idea I proposed?

 

It asks the question whether or not Jetty uses the Java_Home environment variable by default. That is, even when you specify a different JVM path in jetty.lax.

 

Step 1: Set the VM setting in jetty.lax to its original value (C:\ColdFusion2021\jre\bin\javaw.exe on Windows)

Step 2: Navigate in a terminal to that bin directory, and run the command java -version. Write down the version.

Step 3: Run the cfexecute code I gave earlier (or its equivalent). Compare the Java version in the output with the result in Step 2.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2022 Oct 28, 2022

Copy link to clipboard

Copied

I wish to share this Adobe ColdFusion Feature Request: https://tracker.adobe.com/#/view/CF-4215630.

Just in case there is a connection to the issue discussed here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 28, 2022 Oct 28, 2022

Copy link to clipboard

Copied

I work with Eric and he's out of the office for a bit so picking up where he left off.  I'm the admin of the CF system.  When run like what you have the inbuilt Java is 11.0.1 and the command through a directed Java with the --list-config pulls back the Java version it's set to run against so 11.0.16.0 or 11.0.17.0 depending on what we have it set to for testing.

 

When the Jetty is using the 11.0.17.0 it loads and looks to be running fine but throws 500 errors when commands are setn to it.

 

Can you go into your ColdFusion2021\cfusion\jetty\lib folder and see what version your Jetty is from looking at the jar info?  For example ours is jetty-client-9.4.31.v20200723.jar.  Apparently depending on when you got the install media for CF2021 it installs different versions of Jetty and Java with it.  Hence we have the Java 11.0.1.0 because we isntalled the original Gold images years ago.  I'm wondering if this is an issue with ours possibly also because of this having older Jetty versions.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

We did some more testing and the only way CFHTMLTOPDF will work for us under Java 11.0.17 is if we point CF to Java 11.0.17 and the jetty config variable (ax.nl.current.vm) to the VM under the CF21 directory - i.e., [server root]\ColdFusion2021\jre\bin\javaw.exe, which is currently 11.0.1. 

 

We are going to leave it at that.

 

Thanks for everyone's help with this,

-Eric

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 21, 2023 Jul 21, 2023

Copy link to clipboard

Copied

LATEST

I recently upgraded to ColdFusion 2021 Update 9 and I am experiencing a similar issue. When setting the java version in the jetty lax file to any version greater than Java Version: 11.0.16.1 I get a server error.

 

Putting it back to 11.0.16.1 resolves the issue. I am a bit concerned that I cannot run a more secure version of Java. From a security stand point, how serious is this?

 

2nd issue I just came across is that cfhtmltopdf no longer outputs the "Calibri" font. It just displays blank text. Switching to "Arial" works. Any idea what would have changed?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation