TemplateNotFoundException error – ColdFusion 9

I came across a strange error while setting up a virtual ColdFusion 9 sever (Windows 2008 with IIS 7.5). Whilst loading up a test site I got the following ColdFusion error:

Error Occurred While Processing Request
File not found: /index.cfm

On the face of it, it looks like an obvious fix. Surely there is no file by the name of index.cfm in the root of the folder.  Wrong!  The file does exist.  However, if I was to replace it with a simple index.htm file that wold work without any problems.

Digging a little deeper I took at look at the application.log and exception.log in ColdFusion administrator to see if there were any further clues.

Application.log

"Error","jrpp-8","12/26/15","17:43:11",,"File not found: /index.cfm The specific sequence of files included or processed is: C:\Websites\SampleSite\wwwroot\index.cfm'' " 

Exception.log

"Error","jrpp-8","12/26/15","17:43:11",,"File not found: /index.cfm The specific sequence of files included or processed is: C:\Websites\SampleSite\wwwroot\index.cfm'' "
coldfusion.runtime.TemplateNotFoundException: File not found: /index.cfm
	at coldfusion.filter.PathFilter.invoke(PathFilter.java:90)
	at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
	at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
	at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
	at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
	at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
	at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
	at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
	at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:53)
	at coldfusion.CfmServlet.service(CfmServlet.java:200)
	at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
	at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
	at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
	at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
	at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
	at jrun.servlet.FilterChain.service(FilterChain.java:101)
	at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
	at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
	at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
	at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
	at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
	at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
	at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
	at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
	at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

The double single quotes at the end of index.cfm seemed to be very odd.  My setup was very basic apart from that fact that the IIS application pool identity was running with its own user.  It would seem to suggest this user account could not compile and write to ColdFusion WEB-INF folder.

The ColdFusion service needs to run on this same user account.  On the server in Services right click on “ColdFusion 9 Application Server” and select properties.  On the “Log On” tab select “This Account:” and enter the username and password used in the application pool identity.  Once done don’t forget to restart the service.  Reload the website and the error will disappear!

Migrating from Mango Blog to WordPress

I finally decided to move from Mango Blog to WordPress purely down to hosting and its costs.

I was on the hunt for something that would take all my posts, categories and comments and import them into the WordPress. I finally came a cross a blog entry by Marcos Placona where he wrote a script in CFML to import from Mango Blog to WordPress.

The scrip can be downloaded from here Mango2WordPress.

The script is pretty straight forward add the two data source names (Mango Blog and WordPress) and then run the scrip on the ColdFusion/Railo server.

I came across two issues

  1. No variable for set up for the table prefix in the Mango Blog database
  2. Everything but the post contents got migrated. Since I did not have many blog posts it was easy for me to copy and paste them over.

[Macromedia][SQLServer JDBC Driver]Object has been closed.

I came across this very odd error today while trying to write a query in Coldfusion 9. I ensured the query worked in SQL Management Studio but each time I called the CFM page I was presented with the following error:

[Macromedia][SQLServer JDBC Driver]Object has been closed.

Having double checked everything, from my code to the set up of the server and DSN – everything looked perfectly as it should.

Finally, I stumbeled upon the solution: either resart the Coldfusion server or make a change to the DSN. I hope this helps saves others time as it took me forever to work this out.

ColdFusion Spool .cfmail Mail

Have you ever wondered why emails are not being delivered but keep building up in your ColdFusion spool folder? If so you have then probably seen an error message to this effect:

cfmail spool folder not processing MailXXXXXX.cfmail files.

This really got me going, one minute the emails was working and next minute it all stopped and nothing had changed. Being a live server the emails kept building up in the spool folder. Evenutally I figured out a solution or two.

A lock in the system can sometimes cause this kind of a behaviour. The first point of call would be to restart your ColdFusion Server. If this does not work then you need to look for the 0byte folder in your spool folder, this will be a corrupt file, remover this and you will see all your emails being sent out.

Images not displaying in CFDOCUMENT PDF

When creating a PDF which contains images I found that it worked in my development envirmonet but would not work in the production environment. The only difference was that the production environment had an SSL. Rightly so the SSL was causing the issue and so the PDF would display a small box with a red cross.

To get round this there are a couple of ways. You can ensure that your certificated is added to the trusted certificate store (runtime/lib/trustedStore). You can use keytool to list/view/import… certificate in the certificate store. This can get pretty involved if you are not familar with what you are doing. The other method is very simple and a quick change to the code, it uses the file protocol identifier in the image path and you will find it works a treat!

This is how we insert an image using HTML:

<img scr="https://www.mydomain.com/images/myimage.jpg" width="60px" height="60px">

When creating a PDF where the site has an SSL you simply do the following:

<img scr="file:///d:\mysite\images\myimage.jpg" width="60px" height="60px">

It is a simple as that and it’s a very quick fix and will save you time.