Tuesday, 25 February 2014

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

Update

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.

G'day:
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:

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

Coldfusion-out.log:
Feb 26, 2014 09:24:07 AM Error [http-apr-8500-exec-4] - Connect to localhost:8987 [localhost/127.0.0.1, 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.

server.log:
"Information","localhost-startStop-1","02/26/14","09:21:01",,"ColdFusion: application services are now available"
"Error","Thread-14","02/26/14","09:21:12",,"Connect to localhost:8987 [localhost/127.0.0.1, 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"
"Error","http-apr-8500-exec-7","02/26/14","09:23:03",,"Connect to localhost:8987 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect http://localhost:8987/PDFgServlet/verify"
"Error","http-apr-8500-exec-4","02/26/14","09:24:07",,"Connect to localhost:8987 [localhost/127.0.0.1, 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:

cfusion\jetty\etc\jetty.xml:
<!-- 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">
  <Arg>
      <New class="org.mortbay.jetty.bio.SocketConnector">
        <Set name="Host">0.0.0.0</Set>
        <Set name="port"><SystemProperty name="jetty.port" default="8987"/></Set>
        <Set name="maxIdleTime">50000</Set>
        <Set name="lowResourceMaxIdleTime">1500</Set>
      </New>
  </Arg>
</Call>

cfusion\lib\neo-document.xml:
<struct type="coldfusion.server.ConfigMap">
    <var name="localhost">
        <struct type="coldfusion.server.ConfigMap">
            <var name="hostname">
                <string>localhost</string>
            </var>
            <var name="ishttps">
                <boolean value="false" />
            </var>
            <var name="port">
                <number>8987.0</number>
            </var>

cfusion\lib\neo-solr.xml:
<struct type="coldfusion.server.ConfigMap">
    <var name="solrhome">
        <string>C:\apps\adobe\ColdFusion\11beta\full\cfusion\jetty\multicore</string>
    </var>
    <var name="solrwebapp">
        <string>solr</string>
    </var>
    <var name="solrhost">
        <string>localhost</string>
    </var>
    <var name="solrport">
        <number>8987.0</number>
    </var>

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
EditVerifyEnableDisableDelete
localhostlocalhost89872NOError  
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.

--
Adam