Entries for month: August 2013

CFDump Alternative

ColdFusion , Railo No Comments »

CFDUMP is an invaluable tag, it helps immensely with debugging and viewing your objects, but annoyingly it requires CreateObject(java) to work, which is often disabled on shared hosting for security reasons, or even if you run your own server perhaps you need to keep createObject(java) disabled but still use CFDump.

This alternative custom tag gives you the functionality of CFDUMP using JavaScript instead.

I originally created this for use on cflive.net because createObject(java) is disabled and considering what cflive is intended for cfdump is definitely required. A few people have asked how I did it so I thought I would release it for the benefit of anyone else who may want to use it.

Note that because it uses JavaScript this is only good for generating dumps to the browser. If you wanted to create a CFDump on the server and put it into an email, then this will not help you a sthere is of course no JavaScript there to render the code.

You can try it out at www.cflive.net where I have used it to replace the original cfdump tag, so just use <cfdump var="#cgi#"> for example.

This tag was created using the JavaScript dump code from Net Grow, which I have modified slightly to give the following additional functionality.

  • allow multiple dumps on the same page
  • new label attribute to emulate the original cfdump
  • plus of course to generate dumps via CFML pages.

You can download the tag here.

How to use

  • As a custom tag
    simply drop dump.cfm into your global custom Tags folder or into any folder which you have mapped as a customTags folder in your application.cfc
    or just drop into the same folder from which you are calling it, then call it as per any normal custom tag.
    e.g.
    <cf_dump var="#cgi#" label="CGI Scope">
  • via CFIMPORT
    If you do not know how to use cfimport, then go here
    e.g.
    <cfimport prefix="" taglib="/customTags">
    <dump var="#cgi#" label="CGI Scope">
  • Replace the original CFDUMP tag
    If you want all your existing code to work without any changes then you can simply replace the original cfdump tags with mine.
    Here are example locations where you will find the tag, you can just do a search for "dump.cfm" inside your CF or Railo installation
    • ColdFusion 9 location
      C:\ColdFusion9\wwwroot\WEB-INF\cftags\dump.cfm
    • ColdFusion 10 location
      C:\ColdFusion10\cfusion\wwwroot\WEB-INF\cftags\dump.cfm
    • Railo location
      C:\railo4\railo-server\context\library\tag
      Railo uses a dump.cfc by default, but if you copy dump.cfm into this folder it will take precedence over dump.cfc

Caveats with Railo running on Helicon zoo

Railo 3 Comments »

One of my Railo sites has a scheduled task which is supposed to run every night at midnight, which I noticed recently had not been running as it usually sends me an email. After an initial bit of head scratching the cause was actually obvious, if you understand how helicon zoo works and how Railo runs inside Zoo, if you don't then I suggest reading THIS ARTICLE.

Because Railo runs as an IIS process using Helicon zoo, this means that the application shuts down after a period of inactivity as defined by your application pool settings, this is good in that it conserves system resources for sites which are not very busy, but it is also bad for Railo for several reasons.

  • every time the application pool shuts down, so does Railo/Java.
  • every time the application pool restarts, Railo must start up again, this can make initial page load rather slow.
  • every time Railo shuts down, you lose anything that was cached, this must be reloaded again when railo restarts.
  • scheduled tasks will of course not run when Railo is not running.

for a small site with no scheduled tasks this probably is not an issue, but if you run a site that does a lot of caching and has a slow start up time, such as mango Blog or Mura CMS, then this could be an issue. also if you have any scheduled tasks which you rely on, this also will be an issue.

In my case the problem was I had setup the scheduled task on the default website, which is never used for anything other than accessing the railo admin and running this scheduled task.

In case this is an issue for you then there are several workarounds.

  1. you can Increase the application pool idle timeout, this is how long it will wait until it shuts down when idle.
    app_pool_timeout
  2. setup a scheduled task that calls a CFM page on your site every 5 minutes, which in theory should keep it active, although this may not be the most reliable method.
  3. RECOMMENDED: setup monitoring for your website which makes a http request every 5 minutes, thus keeping the site active. If you do not have your own monitoring system then you can find plenty of options on Google.
  4. There are also plenty of websites out there which offer online cron jobs, many of which are free, you could use one of these to execute your scheduled tasks or just to keep your site active.
  5. Use windows scheduler to run any page on your site every five minutes or just use this for your scheduled tasks instead of railo.
    you can do this using powershell, just set the following command to execute, replacing the url with your own. Make sure you have powershell installed of course.
    powershell.exe -command "(new-object system.net.webclient).downloadstring('http://yourdomain/task.cfm)"
Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds