New to coldbox, having issues getting setup

Hello,

I’m trying out ColdBox as I think it provides a lot of nice features I’d like to use on our dev team. I’m going through the process of getting it setup on my local dev environment, and I’ve got it partially working. I’m hoping someone can point me in the right direction so I can move forward.

We are using a connector from the Cold Fusion 2018 Application Server to Apache for our Cold Fusion projects currently.

So far I’ve installed CommandBox, made two subfolders and made two subfolders off the webroot:
coldboxapps/testapp

I’ve created a test application using the command “coldbox create app TestApp” in the testapp subfolder.

After some googling, I moved the coldbox folder to the web root and restarted the application server.

Browsing to localhost/coldboxapps/testapp gives me the Welcome to ColdBox! page, but a few things are broken on the page.

The “Main” event handler points to the url localhost/coldboxapps/testapp/Main, and I get a 404 when I click on it.

Under the Application Test Harness section, the links to the Testbox runner and browser generate incorrectly.

localhost/coldboxapps/testapp/coldboxapps/testapp/tests/runner.cfm is an example. The links are duplicating the folder structure. I poked around at the source code a bit and saw that the link is being generated with #getSetting( “appMapping” )#. Removing that does fix the link (however, I get a different error which I didn’t want to pursue at this time).

In the main Application.cfc file, I played around with COLDBOX_APP_MAPPING, but that tended to break the application so I’ve left it blank for now.

For comparison’s sake, I spun up the same project in a folder in my desktop and used the Lucee server, and everything works fine. I have to get it working in our environment to actually build applications for it however.

Thanks in advance for any help you can provide!

I’ve made a little progress on this issue. I think I’m missing something fundamental I feel.

I found sample rewrite rules for Apache on the tutorial and popped an .htaccess file containing them in the root of the project directory. That fixed the problem with the Main event handler not working properly.

If I move the project out of its own directory and into the root directory of the web server, almost everything works properly. The test links generate correctly and the tests all run and execute.

Oddly enough, the /healthcheck url doesn’t resolve like it does when I run the project in the embedded development server no matter where my project lives.

I can “fix” the links by removing the #getSetting( “appMapping” )# code from in front of them on the index page on the default project. However when I do that, I get a failed reference to the test runner page. It’s an absolute reference starting with /testbox, which of course doesn’t resolve without that folder being in the root. If I make it a relative reference (…/testbox), something else breaks. I get this error “Could not find the ColdFusion component or interface testbox.system.TestBox”.

All of my issues seem to be related to references not working properly when the project is in the subfolder. I tried to establish a mapping in the Application.cfc file for /testbox but it didn’t work. I’m unclear at this time if I have to do more with rewrite rules or if there’s some configuration I’ve missed along the way. I’m not sure if my inexperience with Apache is holding me up, or if there’s something fundamental I’m missing about Cold Fusion…or Coldbox!

@emonk I’m not a ColdBox guru, but it sounds to me like you created a coldbox app in a subdirectory of the webroot. Then you moved the coldbox app up to the webroot?

After some googling, I moved the coldbox folder to the web root and restarted the application server.

That sounds like the right direction to go, but I’d be concerned about any generated files which still point to the old location. Moving them would not change the generated location. Hence you are seeing testbox specs in coldboxapps/testapp/coldboxapps/testapp/tests/:

localhost/coldboxapps/testapp/coldboxapps/testapp/tests/runner.cfm is an example. The links are duplicating the folder structure.

These issues honestly would (probably) be best solved by 1) wiping the ACF server via box server forget, and 2) deleting and re-creating the coldbox app. With luck, that should solve the issues above.

However, let me backtrack a bit.

We are using a connector from the Cold Fusion 2018 Application Server to Apache for our Cold Fusion projects currently.

Are you referring to this?

https://helpx.adobe.com/coldfusion/kb/coldfusion-apache-manual-connector-configuration.html

I know nothing about the ACF/Apache connector, but improper config of that could easily cause a lot of problems.

Sorry, just saw your follow-up.

Either TestBox needs to be in the web root, or you need to create a Coldfusion mapping to its location. Same for ColdBox.

How did it not work? The mapping should inform CF of the proper location of the testbox/ directory. You need something like the following in your root Application.cfc:

COLDBOX_APP_ROOT_PATH 	= getDirectoryFromPath( getCurrentTemplatePath() );
this.mappings[ "testbox" ] = COLDBOX_APP_ROOT_PATH & "my/path/to/testbox";

As long as you get the mappings set up right, there should be no need to hack around the testbox templates to fix anything. But if you’re going to have Testbox or Coldbox installed in some non-webroot location you need to tell Coldbox where they live. :slight_smile:

Good luck!

Hi Michael,

Thanks for the replies! I’ll try my best to clarify a few things.

I have a working apache-coldfusion dev environment set up locally, that mirrors our test and prod web servers. For my next app, I want to use coldbox for a variety of reasons (looks super cool, reminds me of yeoman which I used in past life for angular, etc), but it will have to live peacefully along all of our existing projects.

My maiden voyage was to get the quick start application working in my currently existing environment, and then follow along with the 60 minute quick start tutorial from there.

In my webroot I made a coldboxapps folder, and there I made a testapp directory. I ran Commandbox in there and generated the default project. I read that I had to move the actual coldbox folder into the webroot for things to work properly, so I did that but left all the other pieces in place.

I’d be concerned about any generated files which still point to the old location. Moving them would not change the generated location.

I’m worried about that too. I’ll have to figure out how to generate a project without pulling down the Coldbox framework every time, and maybe that’s the route I should go.

How did it not work? The mapping should inform CF of the proper location of the testbox/ directory.

The quick start project generates a local testbox folder, and I tried to create a mapping to that but it didn’t work using the method you outlined, but I see what you’re saying now. I have to move the generated testbox folder to the webroot, much in the same way I had to move the coldbox folder.

So basically what I have is
webroot/coldbox
webroot/coldboxapps/testapp
webroot/coldboxapps/testapp/testbox

and that last one should be
webroot/testbox
with the mapping in my Application.cfc

Thanks for the help! I’m going to keep working on this during my afternoon and another person on my project is taking a stab at it as well, so hopefully two heads are better than one.

IMO don’t be moving coldbox and testbox up to the web root. While that may trick CF into finding the files, it’s sloppy and spreads your nice self-contained app all over. Just create a simple mapping in your Application.cfc and now your app is self contained again!

this.mappings[ '/coldbox' ] = COLDBOX_APP_ROOT_PATH & '/coldbox';
this.mappings[ '/testbox' ] = COLDBOX_APP_ROOT_PATH & '/testbox';

Also, I recommend having a /root mapping (or whatever you want to name it) that points to the root of the ColdBox app. use this so nothing is dependent on the web root.

this.mappings[ '/root' ] = COLDBOX_APP_ROOT_PATH;

Then, instead of hardcoding stuff like

/coldboxapps/testapp/foo.cfm
new coldboxapps.testapp.foo()

you can just use

/root/foo.cfm
new root.foo()

and that will work no matter where the ColdBox app lives.

1 Like