Running a non web application with existing coldbox application

Hi all,
Our web application is running on Coldbox 3.8.

Currently, I need to implement a solution which is not web base, but need to run on the existing code as the business logic is extensive and we would like to keep it in one place instead of duplicating the logic. The solution is basically a perpetual process that wait for something to do (by polling the db is the idea at the moment).

The question is, what is the correct way to implement this solution?

My current approach is to write some codes in mytest.cfm (an infinite loop that poll the db and run some code if a job pops up) and run it using CommandBox. But when I try to execute the code in the web application there are multiple “can’t find component” errors such as:

ERROR (5.5.1+00562)

invalid component definition, can’t find component [coldbox.system.orm.hibernate.BaseORMService]

/var/www/coldbox/system/plugins/ORMService.cfc: line 15
13: ----------------------------------------------------------------------->
14: */
15: component extends=“coldbox.system.orm.hibernate.BaseORMService” singleton{

I have checked that the related .cfc files are in the correct directories. And if I try to create the object (eg. BaseORMService) in mytest.cfm, it works.

It may be that my approach to this solution is totally off.

Hope anyone can give me some input?

Thanks so much for your help.

Best regards,

Hi Jodi, I do this exact thing on a few projects. Mostly Rabbit message consumers which I execute inside a Task Runner inside CommandBox inside a MiniBox docker container, running on Docker Swarm. I re-use the business logic from my client’s web apps inside the Task Runners.

Now, there is a longish list of caveats that, depending on your specific code base, may be no issue or may require some refactoring.

  • The business logic was already wrapped up in Box Modules, which can be loaded quickly and easily from inside CommandBox using the loadModule() function. This provides instant-use CF mappings, WireBox mappings, and interception points
  • All of the 3rd party libs we’re depending on are also Box modules. e.g. RabbitSDK, CFCouchbase, Sentry, Hyper, etc which makes them all nicely encapsulated
  • All of the business logic is from proper MVC app, so there is a nice, clear separation of concerns for services and views.
  • The business logic has few or nor hard dependencies on the HTTP mechanics, application/server/request scopes, or the MVC framwork at all
  • it is required to set up any datasources in the CLI that the code requires (this isn’t too hard), as well as any module config.

So, what you want to do is totally possible, but how easy it is will depend on a number of things on your end. For a Task Runner that loads up some stuff and waits in a while/true loop, you just need to catch an interrupted exception, which is what will happen when you stop the task. So something like this:

component {

  function run() {
    print.line( 'Task starting...' ).toConsole();

    // Load modules, set up datasources, etc, etc

    try {
      while( true ) {
        sleep( 500 );
    } catch( java.lang.InterruptedException e ) {
      print.line( 'Task interrupted' ).toConsole();
    } finally {
      // Logic here to clean up
      print.line( 'Task shut down' ).toConsole();



Now, I did notice you mentioned ORM in your post. That’s probably going to pose some significant issues for you, mostly because

  • Neither of the CF engines really ever accounted for Hibernate being used outside of a web server, and they have a lot of dependencies on Application.cfc, which doesn’t exist here.
  • I’ve never tested our cborm module outside of ColdBox so I don’t know if it works. It probably can be made to work, but if cborm has any current hard dependencies on ColdBox, it’s not going to be happy being loaded up in CommandBox. That will take some fiddling to see if it works and what it takes to get Hibernate in general working. You’re probably going to need to test and see if

is supported on Lucee (I’ve never tried it, honesty). Also, you didn’t mention if your web app is running on Adobe ColdFusion or Lucee Server, but CommandBox Task Runners execute on the latest stable Lucee version, so your CFML code will need to be compatible there as well.

This is something you need to address as well. ColdBox 3.x is old. Like REALLY old! We’re up to 6.7.0 now and 3.8 was 11 years ago (2013)! This means your app is likely still dependent on Plugins (which were removed entirely in ColdBox 4) and less likely to be broken into reusable modules (which were introduced in ColdBox 3, but really became a first-class citizen of the framework in v4).

So, you’ve got some pretty big things working against you, but I’m sure it’s all possible if you’re willing to commit the time to it. Being able to have CLI-based daemons running aync logic is super powerful and fun. Also, remember Ortus has consulting plans if your company wants us to work directly with getting this figured out.

Hi Brad,
Thanks so much for the detail explanation. I will give it a try and see if I can make it work. If not, I think I will use the task runner to execute a http request instead. Its not ideal but at least it will work.

We are running Coldbox on Lucee server and we do realize 3.8 is old :pensive: Hopefully we will be able to migrate it to the latest Coldbox soon. Well definitely consider Ortus when the time come :+1:

1 Like

Hi Brad,
What is best way to get in touch with you and Ortus to find out more about your consulting plans and upgrading our Coldbox?

Best way is to email
Copy the link to this discussion to give our team some reference material, and they can reach out to you and set a time to meet and discuss options.

1 Like