[Coldbox-5.0] Loading coldbox config file - component can't be found

Hello,

I’m migrating coldBox 2.63 app -> ColdBox 5.
I’ve replaced the coldbox files and am refactoring the rest of my app.

I’m seeing the following error

Could not find the ColdFusion component or interface config/coldbox.xml.cfm.

Regardless of what path I specify in the Application.cfc, or where I put the coldbox.xml.cfm file … I still get the error.

Even when I put the absolute path to the config file … coldbox can’t find it.

The ColdBox config hasn’t been allowed to be an XML file for a very long time now. I think it was deprecated in 3.x and fully removed in 4.x Check out one of the new app templates and you can see what the current config file looks like. It’s just a CFC file so much easier to manage than XML.

https://github.com/coldbox-templates/advanced-script/blob/master/config/Coldbox.cfc

I’m not sure if we still have our Coldbox 3 migrations guides published anywhere since they were all on the old wiki. Perhaps Luis knows.

Thanks for the reply.
I’ve been tasked with upgrading from 2.6 to 5 - so it’s been a bit of adventure.

I did start out with a fresh installation of CB so I could see how the various files changed.

I’m working my way through our app’s Application.cfc file - which looks like an old coldbox Application.cfc file.
I basically took the current version of Application.cfc written in CFSCRIPT - and brought our code into the methods.

within the onApplicationStart method - it looks like CB gets loaded a little differently.
Now that I know the XML method for the config file isn’t supported - that helps.

On my old onApplicationStart - I’ve got this, which is working right up to loadColdBox()
It looks up the config based on the parameters and is successfully appended the two structures together.
It gets to loadColkdBox and says it that function isn’t defined.

// Get config from DB
var config = server.configuration.setupSiteConfig(instance=var_implementation, applicationname = appName,httphost=cgi.http_host);
structAppend(application, config);
//Load ColdBox
loadColdBox();


....

I notice in the newer version of onApplicationStart(), it's a little different.


The error that you’re getting isn’t actually that the XML file can’t be found, but that the component cannot be found. While perhaps a bit misleading, it actually makes sense. And XML file is not a component (CFC), and so cannot be loaded as one. That’s about the way CF is handling it though, rather than ColdBox.

HTH

Yes, Matt is correct. ColdBox isn’t trying to do anything with XML at all. The only reason that the phrase “xml” is included in the error message is because you gave it a CFC path that has the word “XML” in it! So long as your config file has the default path and name of “/config/Coldbox.cfc” you don’t need to specify it at all. The framework will simply find it by convention.

Regarding the loadColdBox() method, you’re mixing and matching the inheritance and non-inheritance versions of Application.cfc. If your Application.cfc extends “coldbox.system.Bootstrap” then you don’t need any other boilerplate code at all. In the non-inheritance version, the framework is created in your onApplicationStart() method and any references to need to be like this:

application.cbBootstrap.loadColdbox();

The inheritance approach is simpler, but it doesn’t allow you to define an application-specific mapping for `/coldbox’.

That was it. Thanks to both you and Matt.

The newer version that I’m copying from that I installed with commandBox seems to be the non-inheritance version.

Still just stepping through the old Application.cfc - I wasn’t sure what was ColdBox, and what was custom stuff that we added.
It’s an enormous application with lots of “custom configuration”.

WHEEEEE!

I better pull up a bar stool in this forum … I’m gonna be here a while.

The configuration file has not been xml since 3.0. You will have to update to the CFC approach

Luis Majano
CEO
Ortus Solutions, Corp

P/F: 1-888-557-8057

Can you point to me any documentation on what is meant by the CFC approach?

Basically - my approach so far has been to take the old application.cfc file (written in tag based format), and move the various bits over to a application.cfc created by command box.
Some of the functions seem to be there, some of them are not. (maybe a name change or no longer existant)

Unfortunately - the app I’m wokring on is such a pile of spaghetti - I can’t just start from scratch.

You’re mixing conversations here. Luis was referring to the ColdBox config CFC which is in /config/Coldbox.cfc and documented thoroughly in our ColdBox docs.

https://coldbox.ortusbooks.com/content/full/configuration/coldboxcfc/

If you want to learn about the Bootstrap (which involves your Application.cfc) then read about it here:

https://coldbox.ortusbooks.com/content/full/configuration/bootstrapper.html

If you’re really in over your head, Ortus does provide consulting services. You’re welcome to get some support hours where we can actually sit down with you on a screenshare and get all this working with you :slight_smile:

https://www.ortussolutions.com/services/support

Thanks for the quick reply and the links.
I’ll check those out.

I don’t doubt that eventually I’ll get with Ortus for some consulting.
Going through the code I’ve inherited, I’m not sure what was hacked in, what was early coldBox functionality, etc.

If only the rest of the internet was as well documented as coldBox.

:slight_smile:

You can just use the search feature in Gitbook to find these. The new gitbook upgrade a couple months back broke those URLs.

https://coldbox.ortusbooks.com/getting-started/configuration/coldbox.cfc

https://coldbox.ortusbooks.com/getting-started/configuration/bootstrapper-application.cfc

Thanks. I ended up adding extends=‘coldbox.system.Bootstrap’
to the Application.cfc file, which resolved the error.

I’m not real clear on the difference between the examples that have the extend bit - and those that don’t.

component extends='coldbox.system.Bootstrap'



Thanks for the reminder on the current docs.

After re-reading a couple times, it seems like there are two “ways” to handle the Application.cfc setup.
One uses extends (inheritance), and one doesn’t “composition”.

From the example shown - it doesn’t look like you need to have each onRequestStart, onRequest, etc - when extending the component.

When using the “composition” method - how does one call the reloadChecks(); function?
When using inheritance - it works. When using composition, it says the function can’t be found.

My OnApplicationStart function is choking on the loadcoldbox() call.

I don’t know what this means. I need the actual error message and stack trace, and possibly the code to have any clue what’s going on.

After re-reading a couple times, it seems like there are two “ways” to handle the Application.cfc setup.
One uses extends (inheritance), and one doesn’t “composition”.

Yes, that’s correct. Inheritance has less boilerplate but composition is required if you want to use this.mappings to define where /coldbox lives. At the end of the day, they both do the same thing.

From the example shown - it doesn’t look like you need to have each onRequestStart, onRequest, etc - when extending the component.

That’s correct, they are inherited from the super class (bootstrap)

When using the “composition” method - how does one call the reloadChecks(); function?
When using inheritance - it works. When using composition, it says the function can’t be found.

In the composition version, all of the methods from the Bootstrap are not just right there inherited in the CFC you, instead they are referenced the via the componsed bootstrrap CFC instance that you create in app start.

application.cbBootstrap.reloadChecks();

Based on what you mention, I think the composition method is the one I should use.
I added application.cbBootstrap to the method calls.

Would it be preferable to start a new thread for the different errors I’m getting as I continue the upgrade?

Yes please. If you’re looking for more stream-of-conscious support I’d recommend also checking out the CFML Slack team’s #box-products channel.