Changing from a dynamic root to a directory

I was just told something I was doing was not necessarily going to be an option so I have to ask this question. Examples and instructions don’t exactly seem to be doing what I was expecting, but I might be assuming too much.

Typically I create a website my creating a directory in my web root, dumping the code there, CF mapping /coldbox to wherever I have CB installed then creating a local host record (and apache vm host) to that directory so I can not only use something like DEV.MYSITE.COM to get to the site, but also so that I can ALWAYS treat everything as if it is in the root.

But I’m told the server I am going to publish to may not give me that option (don’t ask) so I want to be able to NOW do something like LOCALHOST/MYSITE. Changing NOTHING, if I do that, I get an error saying that it cannot find my path “model.someservice”…which I assume because really it needs to be “mysite.model.someservice” (which tested, works)…but obviously I don’t want to have to go and change all my code that already exists.

I expected to be able to change one or two special variables in application.cfc, but both tests failed.

what am I missing?

Mike Craig

Mike, it is never good practice to put sites into the webroot like this. If the webroot is ever hacked then they get access to every single site in the directory.

I always do this in development.


Then each new project is added to the myProjects folder, but myProjects is never web accessible. There will not be 1 hosting provider that will do this any other way.

So with that out of the way, what is it that your actually trying to do with your method?

I don’t think it matters how many directories deep you want to go…I just cannot get a directory to “behave” as the root of my site. All I know is regardless of where I put it, if I use a host entry to treat that directory as the root of my site, my “normal way” of doing things, works fine but localhost/mysite does not so I assumed

one of those two settings would have to change but nothing I change seems to make any difference. If I append the first with “/mysite” I cannot see the configuration file, if I add “/mysite” to the latter, the cb pathing to classes does not work but what I don’t want to do is change my pathing to “mysite.model.xxxx” because if I move it…well, I’m sure you can see how that would not be preferrable.


You shouldn’t need to change either of those settings as they are auto-detected unless you are going to be using remote proxies or Flex gateways.

Regarding your model paths, a ColdFusion mapping should help fix that. Depending on how you’re using WireBox, scan locations and directory mappings are already essentially relative.

Can you elaborate on what errors you are receiving when you try to run your app in a sub directory? There should be a coldbox setting called “appMapping” automatically created for you which can also be helped to make other settings dynamic. Just keep in mind that appMapping will be an empty string if your app is in the web root.



ColdBox Platform Evangelist
Ortus Solutions, Corp

ColdBox Platform:

ok…removed any customizations of those settings.

“localhost” is my webserver and that points to c:/sites

/tdcc is now a directory under c:/sites

I copy all the code into c:/sites/tdcc

I access the site via “localhost/tdcc/index.cfm”

I get

# Could not find the ColdFusion component or interface# model.basecollector.
Ensure that the name is correct and that the component or interface exists.

At this point I am assuming this is getting hit on the first wirebox mapping


which is defined as

component extends=“model.basecollector” accessors=“true” singleton {

property name=“injector” inject=“wirebox”;

property name=“dao” inject=“tdcc.model.system.TDCCModuleIntegrationDAO”;

property name=“moduleservice” inject=“coldbox:moduleService”;

property name=“loaded” type=“boolean”;

TDCCModuleIntegrationService function init() {



return this;



when the site was being aliased by vmhosts and accessed as hosted site, this error does not occur. If I change the model. references to tdcc.model., it works and then fails on the next class being wireboxed.


I maybe misunderstanding the situation, but coldBox handles mapping concept for you!

When I’m using inject="" or getmodel(""), the model directory is not explicitly typed, because coldbox’s model look up routine includes the model directory.

for example, if my directory structure is

/ ->webroot












then in my handler (general.cfc) I write the following and coldBox will find it
local.oService = GetModel(“forum.forumService”);
local.oService = GetModel(“auth.loginService”);

also when i’m injecting, i do not use the “model” directory

And for the links that get built, i use coldBox’s appMapping configuration and the function event.buildLink(“link to build”)

The only time the above is an issue is when a module has the exact same “model” path as another module or parent application. Therefore, I have started including my own DSLBuilder configuration in every module to force a naming space convention, to eliminate any future conflicts.

so in my above example, i originally had
local.oService = GetModel(“auth.loginService”);

and now I reference that by
local.oService = GetModel(dsl=“myCBModule:auth.loginService”);

I hope this helps and doesn’t confuse the situation.

Not at all…and after reading it I got horribly excited…so being early enough in the process I thought I’d give it a try but I immediately but for some reason, this magic does not work for me. I immediately get an error that components are not available. I wonder why?


but man would I love for that to work