Using ColdFusion frameworks on shared hosting

I have had problems in the past when wanting to use a ColdFusion framework such as Mach II, Model Glue, ColdSpring or Reactor in a shared hosting environment.

For example, suppose you install ColdSpring under the /coldspring directory, then everything works just fine. Then another site on the same shared server also installs coldspring, and then goes on to create a /coldspring ColdFusion mapping to point to their /coldspring directory. Suddenly your site will try to run their copy of the ColdSpring and not yours. Not so good.

It turns out to be quite easy to get around this by simply renaming all of the component references in whatever framework you are using so that the framework is sitting under your own custom directory. For example, suppose your company is “ACME Web Products” then you can create a directory on the site called “/acme” and pop your copy of ColdSpring, or Mach II etc. under there.

For coldspring you would rename as follows:

Rename ["coldspring.] to ["acme.coldspring.]

Rename ['coldspring.] to ['acme.coldspring.]

(leave out the square brackets, of course)

This handles cases where the strings use double quote or single quotes in the framework code.

The when you want to instantiate your copy of ColdSpring (or Mach II etc), just use your extra directory name:

<cfset beanFactory = createObject("component","acme.coldspring.beans.DefaultXmlBeanFactory").init()>

There may be a couple of other references that may need to be changed, but they are usually quite easy to fix.

This entry was posted in ColdFusion and tagged , . Bookmark the permalink. Both comments and trackbacks are currently closed.

11 Comments

  1. Posted October 29, 2007 at 7:25 am | Permalink

    FYI – I am running reactor on HostMySite with no problems.

  2. Posted October 29, 2007 at 12:09 pm | Permalink

    ColdFusion 8 introduced application specific mappings and custom tag paths. Custom tag paths are the same as component paths. Simply add the following to your Application.cfc.

    <cfset THIS.customTagPaths = listAppend(customtagpaths, expandPath(‘/coldspring’)) />

    THIS.customTagPaths is a common delimited list of custom tag / component directories. The above example uses the expandPath function to supply a relative directory.

    You can read more here:
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=appFramework_04.html

  3. Posted October 29, 2007 at 2:02 pm | Permalink

    @Dan, If you are running CF7 or lower then my guess would be that noone else on the same server has a /reactor mapping. If anyone else installed reactor on the same server then created a mapping then I expect your site would try to use their copy of reactor instead.

    @Adrock, I have heard about this but not looked into it. This was one of my biggest gripes with CF and this new change is outstanding news. Thanks for the link!

  4. Posted October 29, 2007 at 2:20 pm | Permalink

    Renaming stuff in the core files is a pretty dangerous practice and it makes it very hard for you to upgrade to later versions of the frameworks. If a framework uses variables for paths in createObject() a simple find’n'replace might not catch everything and then you’ll have subtle bugs to track down. Golden rule: never touch a framework’s core files!

    Better to avoid hosting companies that let you hijack other people’s paths. CrystalTech is one that should be avoided in this situation (unless you’re on CF8 – see Adrock’s comment). HMS do NOT have this problem as they only let you create mappings that include your customer number (so you CAN’T create /coldspring, only /coldspring_h1234 or something similar). So Dan will not be affected because he’s on a smart hosting company.

  5. Posted October 30, 2007 at 1:50 am | Permalink

    Hi Sean, yes I do agree in principle about never touching a framework, but if the alternative is not to be able to use them all then I would be willing to use a transformed version. In particular with a change such a moving the location of the components it seems much less risky than changing actual behaviour. Generally if any bugs were introduced, I expect they would all be of a similar nature – i.e. "component not found".

    Of course, the best solution is to use a host such as HMS (I was not aware of their mapping policy – good to know there are intelligent CF hosts available), but if this is not possible then I would certainly consider the approach above.

    Overall, this is perhaps not much of an issue any longer with new projects and CF8 site mappings available.

  6. TP
    Posted April 10, 2008 at 2:18 pm | Permalink

    I realize I’m responding to this one late in the game…sorry about that. I just found this post recently after having started 2 different CF accounts with HostMySite for clients. I have no regrets. Their service has been impeccable so far.

    I did try using the method specified by Adrock above but to no avail, I’m afraid. I need to use Model-Glue and ColdSpring.

    I did verify that my account is indeed on ColdFusion 8 and not MX7.

    So, basically, based on Adrock’s suggestion, I added the following to my Application.cfc file:

    <cfset this.customTagPaths = listAppend(customtagpaths, expandPath(‘/coldspring’)) />
    <cfset this.customTagPaths = listAppend(customtagpaths, expandPath(‘/ModelGlue’)) />

    Am I doing anything incorrectly here?

    (NOTE: the good people at HMS have told me they will definitely look into this and get right back with me on how it can be set up but in the meantime I’m trying to see if there is any info out there on workarounds already in use.)

    Thank you for any additional suggestions any of you might be able to provide!!

    Best,
    Tony

  7. Posted April 10, 2008 at 3:19 pm | Permalink

    Hi Tony

    MG and CS should work fine at HMS without any mappings or custom tag paths. I haven’t tried, but I understand this to be the case.

  8. Tony
    Posted April 10, 2008 at 6:51 pm | Permalink

    Hi Kevan,

    When I spoke on the phone to a HMS tech support rep earlier today, he was looking on the server to see if they had it set up and it sounded like they did have ColdSpring but not Model-Glue set up. I’m flummoxed by this considering others sound like they are using it without any problems. But then when I actually speak to HMS they keep telling me it’s not installed but I can put the MG installation packages at the root of my site and then create a mapping.

    Not sure what to do at this point.

    Thanks again!
    Best,
    Tony

  9. Rony Fayyad
    Posted April 22, 2008 at 4:01 am | Permalink

    I have just uploaded a MG site using CF8s mapping and it all works fine.

    I am using HMS.

    But I have noticed that the site is very slow.

    Sometimes a page loads in 10-15 seconds and then other times it loads in less than 1 second.

    I just signed up with them two days ago and I am pretty disappointed with the speed.

    I have ensure that all MG reload variables ( setting in coldspring.xml ) are set to false – so the site will not reload all the time. This does not seem to be the problem.

    Has anyone experienced this with HMS ?

  10. Pedro Bezunartea López
    Posted March 3, 2009 at 4:27 am | Permalink

    No luck… I’m trying to use SAVA cms, but I keep running into the same problem. Sava is installed in a shared environment, the application is installed in the path: "http://cfserver/nw", and the error I’m getting is:
    "Could not find the ColdFusion Component coldspring.beans.DefaultXmlBeanFactory.
    Please check that the given name is correct and that the component exists.

    The error occurred in /devel/nw/config/settings.cfm: line 71
    Called from /devel/nw/config/settings.cfm: line 48
    Called from /devel/nw/config/settings.cfm: line 15
    Called from /devel/nw/config/settings.cfm: line 1
    Called from /devel/nw/Application.cfc: line 29

    70 :
    71 : <cfset application.serviceFactory=createObject("component","coldspring.beans.DefaultXmlBeanFactory").init() />"

    I added the following to Sava’s Application.cfc, inside the tag <cfcomponent>:
    <cfset customtagpaths = "/devel/nw">
    <cfset this.customTagPaths = listAppend(customtagpaths, expandPath(‘/coldspring’)) />

    Did I do something wrong? Thanks for the post!

    Pedro.

  11. Posted March 4, 2009 at 6:15 pm | Permalink

    Hi Pedro, unfortunately, just adding coldspring to the custom tag
    paths won’t work. You will either need to

    a) Put the coldspring into the root directory of your website (which
    may or may not be a problem on a shared host, depending on the host)

    b) Put coldspring in a subdirectory (e.g. ‘/nw/coldspring’), rename all of the components as described in this entry (with the understanding that some functionality of the framework may become unavailable), the create coldspring using:

    <cfset application.serviceFactory=createObject("component","nw.coldspring.beans.DefaultXmlBeanFactory").init() />

    If at all possible, use a shared host that does would not allow anyone to create a "coldspring" mapping (e.g. HMS) and all should be fine.

    Hope that helps.