Entries Tagged as 'ColdFusion'

New live CFML test console for ColdFusion and Railo

ColdFusion , Railo 13 Comments »

Last week while answering some coding questions on a discussion list I needed to post some example code, which meant if I wanted to test the code first then I needed access to a cf server. As I tend to do most of my list replies etc on my mobile device, I do not have a local CF installation to test with. 
With PC sales dropping and mobile devices sales far exceeding PC sales these days, I would imagine most other people are doing most of their community activity on their mobile device as well.

I then considered how often I have seen other devs posting code snippets and saying "this is not tested code as I do not have access to a cf/Railo  server right now", or the question is about Railo and you only have CF or vice versa, so it must be a fairly common scenario.

This made me think to myself "wouldn't it be handy if there was a web page I could go to where I could quickly just type some code into a form, submit it and the code would be executed and tell me if there were any errors and give me some debug output, surely someone has written such a tool ? 
So I Googled it and was surprised that such a tool did not exist, that I could find, at least not for CF.

Well it seemed like such a simple app to write and it has been a long time since I did any coding as I simply do not get the time these days, so I thought I would do it  myself, and here it is.

www.cflive.net

You can test code against both ColdFusion 9 and Railo simultaniously.
You can s
electivenable debug output
You can use virtually all CFML tags and functions, excluding file read/write and Java for obvious seurity reasons.
Your code is saved into a session and form automatically re-populated so you don;t have to keep re-typing code.

Please give it a try and leave me some feedback, feel free to try and hack it and find any vulnerabilities or bugs, as long as you let me know about them.

CFIMAGE "Unable to create temporary file" error

ColdFusion No Comments »

Ever get the above error when trying to use CFIMAGE to resize images?

The cause is related to running security sandboxes and not running CF under the SYSTEM account.

If you are running a standard out of the box installation of ColdFusion which is running under the SYSTEM account by default, then CFIMAGE will use c:\windows\temp for creating its temp files, and that is the path you would need to put in your sandboxes.
But if you are running ColdFusion under a dedicated user account (as you should be) then CF will instead use that users temp folder.

e.g.

If your ColdFusion service runs under a user called "coldfusion", then the temp path will be

c:\users\coldfusion\AppData\Local\Temp

So if you use security sandboxes then you need to add the following paths to your security sandbox.

c:\users\coldfusion\AppData\Local\Temp\
c:\users\coldfusion\AppData\Local\Temp\-

If you are not sure what temp path is being used, run the following bit of code on a CFM page to find out.
 

<cfscript> 
writeoutput("Temp Dir : " & createobject("java","java.lang.System").getProperty("java.io.tmpdir") ); 
</cfscript>

 

Obviously we use security sandboxes on our servers and we also lock down ColdFusion, if you do not do either of those things then you probably will never have this issue, bit then you will probably have a hacked server anyway, so this would be the least of your worries Smile

ColdFusion SOLR collections mysteriously stop working

ColdFusion 5 Comments »

Had an issue this week where all SOLR collections on one of our ColdFusion 9 servers stopped working, and SOLR was not accessible from the CFADMIN either, with none of the collections showing.

Trying to add a new collection in the CFADMIN would result in this error

An error occurred while creating the collection: org.apache.solr.common.SolrException. Check the Solr logs for more detail.

 

The websites would be giving the error

The collection COLLECTION_NAME does not exist

Having never used SOLR, this took a fair bit of digging to resolve, Google turned up plenty of other people having this error but no solutions.

It turns out that whenever a SOLR collection is created, a set of configuration files are also copied into the location of the collection.

E.G.
You create your collection at
D:\wwwroot\mydomain.com\wwwroot\SOLR\collections\mycollection

Inside this folder will created a "conf" folder which contains a bunch of config files which SOLR needs to read in order to initialise and use your collection. these are copied from C:\ColdFusion9\solr\multicore\core0 on a default installation.

The first file it looks for is solrconfig.xml, if it cannot find this file then it will throw a configuration error and the default behaviour of SOLR is to simply abort when this happens, thus SOLR completely stops working.

To find out which collection is causing the abort you can check the SOLR admin, which by default is on http://127.0.0.1:8983/solr/ (thanks Jeff).
This will give you an error showing you which collection is causing your problem, the error should look like this

java.lang.RuntimeException: Can't find resource 'solrconfig.xml' in classpath or 'D:\wwwroot\mydomain.com\wwwroot\search\collections\mycollection\conf/', cwd=C:\ColdFusion9\solr

There are 2 ways to fix this.

  1. Restore the missing files to the above folder from your backups.
  2. Remove the collection form SOLR
    open C:\ColdFusion9\solr\multicore\solr.xml
    And remove the offending collection.
    Restart the SOLR service.

 

Now you should also notice on the SOLR admin error that it says:-

If you want solr to continue after configuration errors, change:

<abortOnConfigurationError>false</abortOnConfigurationError>

in solr.xml

This is actually untrue, I tried this and could not get it to work, so went and posted on the SOLR forums only to discover that this feature was actually removed long ago, even more odd is that it was voted to be removed by most of the community. Why they would vote to remove a feature that would stop SOLR from crashing and make it more stable is beyond me.

So what this means is that SOLR is completely unsuitable for shared hosting, where other users are going to cause this problem all the time, if someone deleted their collection, deleted their website due to rebuild or moving hosts, any action that removes the collection files is going to break SOLR.
The only safe way to remove a collection is with <cfcollection action="delete">

 

How to get around tag restrictions in MangoBlog editor

ColdFusion , Railo No Comments »

MangoBlog uses TinyMCE editor when adding/editing articles and pages, which by default will strip out certain tags, including iframe tags, which I needed for posting youtube videos.

The solution is actually very simple.

open up the admin/editorSettings.cfm

and add the following line with any tags[parameters] you want to allow.

extended_valid_elements : "span[class|style],code[class],iframe[src|width|height|name|align|frameborder|scrolling]",

 

In addition if you have “script protection” enabled, then this will replace certain tags (such as iframe) with the text “InvalidTag”. Either your ColdFusion/Railo Admin has Enable Global Script Protection turned on or your Application has scriptProtect set to true. This would be set in either the CFAPPLICATION tag or the This scope of your Application.cfc file.

below is the full code with my amendment.



<!-- TinyMCE --> 
<script type="text/javascript" src="assets/editors/tinymce_3/jscripts/tiny_mce/tiny_mce.js"></script> 
<script type="text/javascript"> 
    <mangoAdmin:Event name="beforeTinyMCEinit" /> 
    tinyMCE.init({ 
        mode : "specific_textareas", 
        editor_selector : "htmlEditor", 
        theme : "advanced", 
        plugins : "table,save,contextmenu,paste,noneditable,asffileexplorer", 
        entity_encoding : "raw", 
        theme_advanced_toolbar_location : "top", 
        theme_advanced_toolbar_align : "left", 
        theme_advanced_path_location : "bottom", 
        theme_advanced_buttons1 : "bold,italic,formatselect,styleselect,bullist,numlist,del,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,removeformat,charmap,code,help", 
        theme_advanced_buttons2 : "", 
        theme_advanced_buttons3 : "", 
        paste_remove_spans: true, 
        extended_valid_elements : "span[class|style],code[class],iframe[src|width|height|name|align|frameborder|scrolling]", 
        theme_advanced_resize_horizontal : false, 
        theme_advanced_resizing : true, 
        relative_urls : false, 
        remove_linebreaks : false, 
        strict_loading_mode: tinymce.isWebKit, 
        document_base_url : "<cfoutput>#blog.getbasePath()#</cfoutput>", 
        <cfif len(currentSkin.adminEditorCss)><cfoutput> 
        content_css : "#blog.getbasePath()#skins/#blog.getSkin()#/#currentSkin.adminEditorCss#", 
        </cfoutput></cfif> 
        <mangoAdmin:Event name="tinyMCEinit" /> 
        <cfoutput> 
        plugin_asffileexplorer_browseurl : '#blog.getSetting('urls').admin#assets/editors/tinymce_3/jscripts/tiny_mce/plugins/asffileexplorer/fileexplorer.cfm', 
        plugin_asffileexplorer_assetsUrl:'#fileUrl#', 
        file_browser_callback : 'ASFFileExplorerPlugin_browse' 
        </cfoutput>, 
        onchange_callback: function(editor) { 
            tinyMCE.triggerSave(); 
            $("#" + editor.id).valid(); 
        } 
    }); 
    <mangoAdmin:Event name="afterTinyMCEinit" /> 
</script> 
<!-- /TinyMCE –>


Getting Coldfusion working with Helicon APE

ColdFusion 9 Comments »

I recently tried to do some rewrite rules on my ColdFusion site using Helicon APE and could not get them to work for love nor money. It worked fine when rewriting to a non .cfm page, but when rewriting to a .cfm page The result was either a "server error" or a "404.3" error as per the below screenshot

image

The cause of this is due to the wildcard handler that ColdFusion uses, when you hit a url that gets intercepted by APE due to a rewrite rule which then attempts to rewrite to another CFM page this does not get processed by the wildcard handler, instead APE tries to process the request with a standard script map, the result of which will be different depending on how you have your server setup.

If you have a standard non modified CF install then in addition to the woldcard (*) handler you also have a bunch of regular script map handlers for each extension that ColdFusion handles (*,cfm, *.cfc, *.cfswf etc), these will be named "AboMapperCustom-xxxxxxxx".

Each of these script map handlers points to the file "jrun_iis6.dll" which actually doesn't work at all on IIS 6 or IIS 7 and thus these handlers seem to serve no purpose. Why these handlers are even created I cannot say, my best guess is that they are a leftover legacy setting from IIS 5.
the only handler that is able to process Coldfusion files is the wildcard handler which points to the following connector.

jrun_iis6_wildcard.dll

So in order for APE to be able to work with CFM files or any of the other CF related extensions then you need to update all those script map handlers to point to "jrun_iis6_wildcard.dll" instead of "jrun_iis6.dll".

If you are on a shared host and do not have access to the IIS manager, then you can fix this in your web.config file if you are running on IIS 7, if you are on IIS 6 then you will need to speak with your host as IIS 6 does not have a web.config.

Below is an example of the changes you need to make to your web.config.
If Coldfusion is enabled globally on the server then the <remove> statements disable the original handlers (you must use the original/actual names of the handlers), if Coldfusion is not enabled server wide then you don't need these.

The <add> statements creates a new set of handlers with the correct connector, these can be named anything you like as they are specific to your site. If Coldfusion is already enabled on your site (IIS 7 only) rather than globally then you will already have a bunch of entries like this in your web.config, in which case simply update the "ScriptProcesstor" path as below to point to "jrun_iis6_wildcard.dll" instead of "jrun_iis6.dll".






<?xml version="1.0" encoding="UTF-8"?>


<configuration>


<system.webServer>


<handlers>


<remove name="AboMapperCustom-xxxxxxxx" />


<remove name="AboMapperCustom-xxxxxxxx" />


<remove name="AboMapperCustom-xxxxxxxx" />


<remove name="AboMapperCustom-xxxxxxxx" />


<remove name="AboMapperCustom-xxxxxxxx" />


<add name="AboMapperCustom-xxxxxxxx" path="*.cfm" verb="*" modules="IsapiModule"


scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\1\jrun_iis6_wildcard.dll"


resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />


<add name="AboMapperCustom-xxxxxxxx" path="*.cfc" verb="*" modules="IsapiModule"


scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\1\jrun_iis6_wildcard.dll"


resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />


<add name="AboMapperCustom-xxxxxxxx" path="*.cfml" verb="*" modules="IsapiModule"


scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\1\jrun_iis6_wildcard.dll"


resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />


<add name="AboMapperCustom-xxxxxxxx" path="*.cfr" verb="*" modules="IsapiModule"


scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\1\jrun_iis6_wildcard.dll"


resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />


<add name="AboMapperCustom-xxxxxxxx" path="*.cfswf" verb="*" modules="IsapiModule"


scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\1\jrun_iis6_wildcard.dll"


resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />


</handlers>


</system.webServer>


</configuration>

 

Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds