Skip to content

wheels new scaffolds Application.cfc with missing application.wheelsdi assignment in onApplicationStart #2622

@bpamiri

Description

@bpamiri

Description

The Application.cfc generated by wheels new declares a local injector variable in onApplicationStart() but then attempts to use application.wheelsdi — which is never assigned. Since application.wheelsdi is the public 4.0 DI container (replacing the 3.x application.wirebox), the local variable should be assigned to it.

Reproduction

wheels new test-app --datasource=test --reload-password=PLACEHOLDER
cat test-app/public/Application.cfc

The generated onApplicationStart():

function onApplicationStart() {
    application.env = duplicate(this.env);
    injector = new wheels.Injector("wheels.Bindings");

    /* wheels/global object */
    application.wo = injector.getInstance("global");
    initArgs.path="wheels";
    initArgs.filename="onapplicationstart";
    application.wheelsdi.getInstance(name = "wheels.events.onapplicationstart", initArguments = initArgs).$init(this);
}

application.wheelsdi is never assigned. On first request, the last line throws because the application-scoped reference is undefined.

Impact

Every new application scaffolded by wheels new fails to boot until the user manually patches Application.cfc. Since this is also a framework boilerplate file that applications shouldn't customize, that's an uncomfortable workaround.

Suggested Fix

Assign the injector to application.wheelsdi so it matches the documented 4.0 DI container name and is available throughout the application:

function onApplicationStart() {
    application.env = duplicate(this.env);
    application.wheelsdi = new wheels.Injector("wheels.Bindings");

    /* wheels/global object */
    application.wo = application.wheelsdi.getInstance("global");
    initArgs.path="wheels";
    initArgs.filename="onapplicationstart";
    application.wheelsdi.getInstance(name = "wheels.events.onapplicationstart", initArguments = initArgs).$init(this);
}

This is consistent with the 4.0 migration path (application.wireboxapplication.wheelsdi) documented in the 4.0 release audit.

Environment

  • Wheels CLI: 4.0.0 (stable, brew install wheels)
  • Scaffold command: wheels new <name> --datasource=<ds> --reload-password=<pw>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions