[Coldbox-3.6.0] Multiple fwreinit=1 : Cache default is not registered

Hi everybody,

First post here :slight_smile:

We use ColdBox 3.6 for our CMS and also use the SES interceptor to create friendly URL’s for all the pages created in the CMS.
Once a new page gets created, or it’s title gets modified we need to reload the SES interceptor / routes.cfm so that the new SES rules will work.

Until this point we have been doing this with calling the site with the ?fwreinit=1 param after the modification in the CMS. This works 95% of the time and reloads the SES rules just fine. However, once multiple users are working in the CMS and the ColdBox reload gets fired multiple times we run into the following error in our logs:

# Cache default is not registered.
Valid cache names are

The error occurred in W:\coldbox36\system\cache\CacheFactory.cfc: line 192
Called from W:\coldbox36\system\ioc\scopes\CacheBox.cfc: line 34
Called from W:\coldbox36\system\ioc\Injector.cfc: line 260
Called from W:\coldbox36\system\web\services\PluginService.cfc: line 137
Called from W:\coldbox36\system\web\services\PluginService.cfc: line 153
Called from W:\coldbox36\system\web\Controller.cfc: line 371
Called from W:\coldbox36\system\web\services\ExceptionService.cfc: line 40
Called from W:\coldbox36\system\Coldbox.cfc: line 350
Called from W:\test\flexfusionCore\Application.cfc: line 442
|

And if this error occurs we’ve discovered the new SES rules are not active :frowning:

This leads me to the following 2 questions:

a) Is there any way to solve the error above?
b) Is there any other way of reloading the SES configuration besides doing a full Coldbox reload with fwreinit?

Thanks in advance,
Rick

Rick,

Can’t vouch for the error message, but I will ask how you are adding the new SES routes? I may have a solution that will remove the need to re-init the framework every time.

Andrew,

We add them in the routes.cfm using the addRoute routes function. Below a simplified version of our routes.cfm. We ask the sesManager (Custom component that communicates with the CMS database). for the rules. It returns an array with all the rules from the CMS. Then we loop over the array and add them using addRoute

<cfset addRoute(pattern=rule.pattern,handler=rule.handler,action=rule.action,matchVariables=rule.matchVariables)>

Any reason your not using DI over storing it in the application?

Why not use the addRoute when adding pages as well? Then there will be no need to re-init the application.

Also is there any reason the routes aren’t using a more simpler route?

like

mydomain/page/cmspage-slug

Then you would only need one route, something like this

<cfset addRoute(pattern="/page/:cmsslug",handler=rule.handler,action=rule.action,matchVariables=rule.matchVariables)>

That way when you hit your handler, the rc will contain the cmsslug = your content page

Looks like your application could use a good makeover, to reduce code if you ask me. Especially when you could easily do this in a handler

component {

function save(event, rc, prc){
var ses = getInterceptor(“SES”);

var routes = ses.getRoutes();
ses.setRoutes( routes );

}

}

Will add the new route when the save handler is called dynamically, which you could be doing using an interceptor instead of the way your doing it now.

Hi Andrew,

Thanks for your message, I wish it was that simple :slight_smile:

The problem is the technical architecture of our application. Our applications consists of 2 parts:

A) The back-end of our CMS, which is an old FuseBox (yuck!) application. This application adds, modifies and deletes pages from the database. We currently have no resources available to rewrite this application in ColdBox.

B) The front-end, which shows the website is a seperate application written in ColdBox 3.6 which we wrote a few month ago.

Both applications have their own application scope, and can only communicatie with each other through the database. After a modification in the CMS in application A, we use CFHTTP to reinit the ColdBox framework in Application B. Not an ideal situation, but one we cannot do anything about at the moment.

So we have no options of adding SES routes in application A, because the ColdBox framework is unavailable.

We can however, create a webservice in application B, which could reload all the SES rules as you explained in your message, which application A could call. I will give this a try!

Thanks for the help so far, will keep you updated!

Rick

Yeah WebServices could work as well, but you still have another option.

You say your using addRoutes, but you don’t say where you are using it. So lets look at this another way then.

Create an interceptor that uses the preProcess event, so when that is fired you can then DI the SES and get a list of the routes from the SES Interceptor, then manually add the ones that are missing from the database as I assume that is where you’re getting them from.

The processing time to do that on each process should be marginal, and would stop you from having to do it the way your doing it now and best of all no re-init of the framework. As the application that is written in ContentBox has access to the database, then you would not need to write a web service in this case. As doing the addRoute in the preProcess will be sufficient enough to keep the routes happy every request.

We can however, create a webservice in application B,

That’s what I was thinking. That will allow your apps to talk to each other. If you end up with multiple clustered servers hosting the front end of the CMS you’d need something like that anyway to add the route to all of them.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com