Coldbox Legacy App DSL Error

I am new to ColdBox and this community and could really use some help figuring out an issue with using Coldbox with our legacy app. I recently installed Coldbox 5.3.1 onto Coldfusion 2018. I am randomly getting an error while trying to use the DI aspects of WireBox. Most of the time it works as intended but periodically, perhaps every 5-6 hours, I get a dependency injection error message. I never get this error on pages that use the Coldbox HMVC framework, just the legacy .CFM pages that are trying to access the Coldbox models.

I went through an old Into the Box talk to help me modify my Application.cfc to get Coldbox to work with the legacy app but I am pretty certain there is something I missed along the way. Reinitting Coldbox seems to temporarily fix the error but I really need to get to the root cause of the issue.

I attached the error message below along with some code blocks. Any help would be much appreciated. Thanks


Message Content:
The target 'models.JobsPlus' requested a missing dependency with a Name of 'JobsPlusAwardDates' and DSL of 'model' {"javaCast":null,"ref":null,"scope":"variables","required":true,"value":null,"dsl":"model","type":"any","argName":"","name":"JobsPlusAwardDates"} 
The error occurred on line 561.


C:\ColdFusion2018\cfusion\wwwroot\coldbox\system\ioc\Builder.cfc, Line 561
	C:\ColdFusion2018\cfusion\wwwroot\coldbox\system\ioc\Injector.cfc, Line 943
	C:\ColdFusion2018\cfusion\wwwroot\coldbox\system\ioc\Injector.cfc, Line 699
	C:\ColdFusion2018\cfusion\wwwroot\coldbox\system\ioc\scopes\NoScope.cfc, Line 49
	C:\ColdFusion2018\cfusion\wwwroot\coldbox\system\ioc\Injector.cfc, Line 417


Application.cfc:

component extends='coldbox.system.Bootstrap' {

    // Application properties
    this.name = "HousingWebApp";
    this.applicationTimeout = "#createTimespan(2,0,0,0)#";
    this.sessionManagement = "true";
    this.sessionTimeout = "#createTimeSpan(2,0,0,0)#";
    this.setClientCookies = "true";

    COLDBOX_APP_ROOT_PATH=expandPath( '/' );
    COLDBOX_APP_MAPPING='/';
    COLDBOX_CONFIG_FILE   = ""; // COLDBOX PROPERTIES
    COLDBOX_APP_KEY       = ""; // COLDBOX APPLICATION KEY OVERRIDE

    // application start
    public boolean function onApplicationStart() {

        application.cbBootstrap = new coldbox.system.Bootstrap(
            COLDBOX_CONFIG_FILE,
            COLDBOX_APP_ROOT_PATH,
            COLDBOX_APP_KEY,
            COLDBOX_APP_MAPPING
        );
        application.cbBootstrap.loadColdbox();

        // Create wirebox injector for legacy code
        wirebox = new coldbox.system.ioc.Injector();

        return true;
    }

    // request start
    public boolean function onRequestStart(String targetPage){

        // Verify ColdBox is loaded
        reloadChecks();

        // Determine if the URL path is destined for ColdBox.
        if(
            // Coldbox is processing these files
            ( arguments.targetPage == '/index.cfm' && len( cgi.path_info) )
            )
        {

            processColdBoxRequest();
            // Returning false prevents the legacy code from also kicking in
            return false;
        }

        // Else proceed to legacy code
        application.cbController.getModuleService().loadMappings();
        application.cbController.getInterceptorService().processState("preProcess");
        return true;

    }

}

view.cfm:

<cfset objJobsPlus = application.wirebox.getInstance("models.JobsPlus")>

models.JobsPlus.cfc:

component accessors="true" {

	// Properties
	property name="JobsPlusAwardDates" inject;

...

I’m not sure if this is the cause of your issue, but I know for sure it isn’t right. You shouldn’t be creating a second injector, which will be overwriting the initial one ColdBox created in memory. That’s defo going to cause some issues in ColdBox. You can just completely delete that line of code. The WireBox instance that ColdBox creates will already be placed in the application scope by default. All you need to do is use it.

Thanks @bdw429s I will give that a try. If I remove that line, what object would I use to access the getInstance method for my legacy pages? Should I even need one? Like I said I’m pretty new to CB and not really sure everything that is going on behind the scenes. I mostly used a bit of trial and error to get where I’m at.

Thanks,

Same as before.

<cfset objJobsPlus = application.wirebox.getInstance("models.JobsPlus")>

WireBox automatically “registers” itself in the application scope just like before. The only difference is, you want to use the actual WireBox instance that ColdBox is creating, not your own, empty one.

Ok thanks that makes sense. Hopefully, that was the cause of my underlying issue