Application Mappings

I am finding it difficult to determine where to change my Application
Settings (In Application.cfc) to successfully find the config file and
run my coldbox application. Here's what I am trying to do.

I currently have my project set up the following way.

/src/
/src/Application.cfc (extends coldbox.system.Coldbox)
/src/com/... (contains all coldbox handlers, config, views, etc.)
/src/www/... (index.cfm, assets, etc.)

I have the following settings.

<cfset COLDBOX_APP_MAPPING = "">
<cfset COLDBOX_APP_ROOT_PATH = "">
<cfset COLDBOX_CONFIG_FILE = "../com/config/Coldbox.cfc">

When I currently run it, I get an error in the CFCApplicationLoader
that it Could not find the ColdFusion Component or Interface C:Users
\username\Documents\Workspaces\Main\nnnn-site-www\src\www\com\config
\Coldbox

You will notice that, the first path "C:\" is getting stripped off and
secondly I am not finding the right combination (app_mapping,
app_root_path) to correctly strip the www and build a path to the
config file.

So what you are saying is that your config file is underneath the webroot in
the com/config directory?

Is this the case? If you have the com directory in the webroot then you
maybe want

<cfset COLDBOX_CONFIG_FILE = "/com/config/Coldbox.cfc" />

Regards,
Andrew Scott
http://www.andyscott.id.au/

The com folder is not a directory that is publicly available (not
available underneath the webroot) so it does not exist on the web
server.

I tried using "..\com\config\Coldbox.cfc" which works but, line 43 of
CFCApplicationLoader strips the leading slash ex. configCFCLocation =
getUtil().ripExtension(replacenocase(coldboxSettings["ConfigFileLocation"],appRootPath,""));

So I end up with "C:Users\username\Documents\Workspaces\Main\nnnn-site-
www\src\com\config\Coldbox" which is not a valid path because it is
missing the \ after C:

Ok, that doesn't make sense unless the src/com is a mapping?

If you can't map by relative to the application, then absolute will be your
only choice. But
C:\Users\username\Documents\Workspaces\Main\nnnn-site-www\src\com\config\Col
dbox is also very valid and will work.

I am also guessing this is you development machine using Eclipse, with your
Eclipse / CFbuilder settings do you have a linked folder to your project or
is it a normal folder.

I think you would be better of trying to explain the folder structure, so we
get a better picture to help.

But what I can tell you is that if you have something like this

ProjectRoot
->src
-->com

What is your root here for the wwwroot?

If it is something like this

ProjectRoot
->src
-->com
->wwwroot

Then ..\src\com is what you need.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of worldclassgeek
Sent: Tuesday, 26 April 2011 1:44 AM
To: ColdBox Platform
Subject: [coldbox:9767] Re: Application Mappings

The com folder is not a directory that is publicly available (not

available

underneath the webroot) so it does not exist on the web server.

I tried using "..\com\config\Coldbox.cfc" which works but, line 43 of
CFCApplicationLoader strips the leading slash ex. configCFCLocation =

getUtil().ripExtension(replacenocase(coldboxSettings["ConfigFileLocation"],a

ppRootPath,""));

So I end up with "C:Users\username\Documents\Workspaces\Main\nnnn-
site-
www\src\com\config\Coldbox" which is not a valid path because it is

missing

I got it to work, I created a dynamic mapping to the application "com"
folder (where I have my coldbox application ie, config, handlers,
views...), which is the same as the coldbox_app_root_path. The
coldbox_config_file still needed a relative path to find the "com"
folder. Here are the settings that worked for me:

<cfset COLDBOX_APP_ROOT_PATH =
getDirectoryFromPath(getCurrentTemplatePath()) & "com">
<cfset COLDBOX_APP_MAPPING = "/nnnn_site_www">
<cfset COLDBOX_CONFIG_FILE = "../com/config/Coldbox.cfc">

You should be able to do it without any mappings, if you can' then the path
to the config file is wrong. Like I said without a guide to help us see it,
we can't help.

If your happy with a mapping then thats good, me I would be looking at the
path and what is being set compared to the path where it lives and see what
the difference is and get it working without the mapping.

Regards,
Andrew Scott
http://www.andyscott.id.au/

Andrew,

Here is my project folder structure, yes it is the dev environment and
no there are no linked folders, we use continuous integration to
deploy and that is how the project is set up with Coldbox 2.6.3, I am
just trying to upgrade to 3.0, we keep the application logic out of
the wwwroot:

projRoot
projRoot/src/
projRoot/src/Application.cfc (extends coldbox.system.Coldbox)
projRoot/src/com/... (this is my app with all coldbox handlers,
config, views, etc.)
projRoot/src/www/... (this is my web root with index.cfm,
coldboxproxy.cfc, assets, etc.)
/coldbox is a mapping to the coldbox platform

Since the /com/config folder is not a virtual directory for the
wwwroot, I think I have to use a mapping.

It still is not working, the config loads now but coldbox still cannot
find the handlers.

It still is not working, the config loads now but coldbox still cannot
find the handlers.

Any reason you went for such a strange structure?

First this has come up before, and I don't see why people are placing the
files all away from the webroot. But that is certainly our your choice, but
if you are going to be using an MVC framework with conventions, this sort of
structure really is obsolete.

However having said that, your application.cfc can load the config files
etc. Your problem is thinking about your hierarchy and that means you should
pay particular attention to this

..\src\com for loading your config file

You have told ColdFusion to go back one directory and look for the src
folder, in reality this is NOT how you have it setup. What you should be
doing is this

..\com to load the config file.

Hope that makes sense, and like I stated you should pay attention to the
structure and how you expect to find files and folders.

As for your structure, sticking everything in the com directory is what I
would say very cinfusing and misleading. Personally as I said that within a
framework that supports MVC, you would be better off following the standard
convention and leaving everything except ColdBox (this is also your choice)
under the webroot.

You will notcie that these directories are heavily protected, to stop people
from loading the files even if they are able to guess your conventions. But
on top of that if you are going to begin using SES and rewrite rules, then
again this makes these directories even securer.

Hope that helps.

Regards,
Andrew Scott
http://www.andyscott.id.au/

See my previous post, this is because your structure is weird and confusing.
But I am betting my bottom dollar your conventions haven't changed for the
where to find handlers, modules etc.

Hope that helps.

Regards,
Andrew Scott
http://www.andyscott.id.au/

Never mind, the handler location is fine.

I appreciate your feedback Andrew, it is a structure that was setup a
couple years ago so we could hide the application directories, but
this may be an obsolete way of handling the application logic. Thanks
again for your insight.

I have not read through very much of this thread.

Keeping all of your directories/files out of the web root is not obsolete. Not only is it not obsolete, but it is highly recommended and preferable to storing everything within the web root. Does everyone follow that practice? No, obviously not. But it is certainly a recommended and worthwhile practice. And it’s easy to do.

Matt,

This discussion came up once before, and you are right in normal circumstances it is not obsolete. However I can give you a URL to try to hack and guess the paths if you want a shot, it is locked down and doesn’t use the standard conventions by ColdBox. And even if you did it is locked down by SES and rewrite rules, and that is what I said if you use SES and rewrite rules you are NOT subject to this problem. And even if it is not locked down by SES and rewrite rules, you are never going to guess the conventions of where things are, or even get any of the core ColdBox to find out either.

So in a well-designed MVC framework, it is obsolete.

Regards,

Andrew Scott

http://www.andyscott.id.au/

Andrew,

I don't think it makes any difference where your files are regarding a
"well designed framework".

I use both options:
1. disable access with a htaccess file (simple as that)
2. Coldbox system and other core files outside the webroot

Ernst