Tuesday 25 February 2014

ColdFusion 11: <cfhtmltopdf> a non-starter. Literally


This sorted itself out after two de-/re-installs. None of which showed any errors, but only the last one installed the PDF stuff. Unimpressed.

This might be me doing something wrong, or a known issue or something, but I can't get <cfhtmltopdf> to work. Which is annoying because for once in my CF career... I actually need to generate some PDFs. Today. Right now.

I am about to get on a plane, upon which I will stay for the "best" part of 30h, excepting a coupla hours in Sydney this afternoon, and another hour in Dubai some time tomorrow (or is it today? Yesterday? TZs do my head in). So I decided I'd PDF-up the ColdFusion 11 docs so I can blog some stuff on the plane. And I decided to use <cfhtmltopdf> to do it.

I'm just working through the docs as I need to (ie: when I get things wrong, I consult the docs to fix them), thinking that predictability of feature syntax is a worthwhile thing to test as well. So I concocted this code:

param URL.htmlUrl;

pdfDir = expandPath("./pdfs/");
pageName = listLast(URL.htmlUrl, "/");
pdfPath = pdfDir & pageName & ".pdf";
cfhtmltopdf(source=URL.htmlUrl, destination=pdfPath, overwrite=true);

(note: I have no idea if that is correct yet, and that's beside the point. But do not take it as valid example code of how to use cfhtmltopdf!)

I ran that, and got this error:

The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request

Error while generating PDF with service manager (http://localhost:8987/PDFgServlet/).

Reason: Error while handling request for service manager (http://localhost:8987/PDFgServlet/).

OK. That's nice.

I had a hunt around in some logs and found this:

"Error","http-apr-8500-exec-4","02/26/14","09:24:07","CFADMIN","Error enabling PDF Service Manager."
    "coldfusion.document.webkit.PDFgErrorHandler$ConnectionVerificationFailedException: Connection verification failed."

Feb 26, 2014 09:24:07 AM Error [http-apr-8500-exec-4]
    - Connect to localhost:8987 [localhost/, localhost/0:0:0:0:0:0:0:1]
    failed: Connection refused: connect http://localhost:8987/PDFgServlet/verify
Feb 26, 2014 09:24:07 AM Error [http-apr-8500-exec-4]
    - Error enabling PDF Service Manager.
Feb 26, 2014 09:24:07 AM Error [http-apr-8500-exec-4]
    - coldfusion.document.webkit.PDFgErrorHandler$ConnectionVerificationFailedException: Connection verification failed.

"Information","localhost-startStop-1","02/26/14","09:21:01",,"ColdFusion: application services are now available"
    "Connect to localhost:8987 [localhost/, localhost/0:0:0:0:0:0:0:1]
    failed: Connection refused: connect http://localhost:8987/PDFgServlet/"
"Information","http-apr-8500-exec-4","02/26/14","09:21:58",,"Initialize client.properties file"
"Information","http-apr-8500-exec-2","02/26/14","09:22:07",,"Pool Manager Started"
    "Connect to localhost:8987 [localhost/, localhost/0:0:0:0:0:0:0:1]
    failed: Connection refused: connect http://localhost:8987/PDFgServlet/verify"
    "Connect to localhost:8987 [localhost/, localhost/0:0:0:0:0:0:0:1]
    failed: Connection refused: connect http://localhost:8987/PDFgServlet/verify"

The only reference to port 8987 I can see in any config files is this lot:

<!-- Use this connector if NIO is not available. -->
<!-- This connector is currently being used for Solr because the
     nio.SelectChannelConnector showed poor performance under WindowsXP
     from a single client with non-persistent connections (35s vs ~3min)
     to complete 10,000 requests)
<Call name="addConnector">
      <New class="org.mortbay.jetty.bio.SocketConnector">
        <Set name="Host"></Set>
        <Set name="port"><SystemProperty name="jetty.port" default="8987"/></Set>
        <Set name="maxIdleTime">50000</Set>
        <Set name="lowResourceMaxIdleTime">1500</Set>

<struct type="coldfusion.server.ConfigMap">
    <var name="localhost">
        <struct type="coldfusion.server.ConfigMap">
            <var name="hostname">
            <var name="ishttps">
                <boolean value="false" />
            <var name="port">

<struct type="coldfusion.server.ConfigMap">
    <var name="solrhome">
    <var name="solrwebapp">
    <var name="solrhost">
    <var name="solrport">

None of that means anything to me, except I do rather wonder whether it's a good thing that it seems both Solr and the PDF engine are both trying to use that port..?

In CFAdmin I have this:

PDF Service Managers
ActionsNameHost NamePortWeightHttps EnabledConnection Status
Connection verification failed for PDF Service Manager: localhost
Check logs for more details.

(that's after trying to start it).

If I go into the EDIT option, I cannot make any changes. It's a form, but it won't let me type anything.

Anyone know what's going on here?

I verified that nothing else is trying to use port 8987.

I tried googling, but drew a blank.

This is, btw, a completely fresh install that I did this morning. According to the installlation log, everything succeeded. I think perhaps it did not.