Lisa
04/17/2023, 6:26 PMX Error: Requested instance not found: '@cbsecurity' The instance could not be located in any declared scan location(s) (models) or full path location or parent or children
-> /app/coldbox/system/ioc/Injector.cfc:482
-> /app/tests/specs/Services/UserServiceTest.cfc:463
-> /app/tests/runner-ci.cfm:25
Lisa
04/17/2023, 6:26 PMjobs:
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name : Start the servers and wait until up
run: ./ci.sh
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: "11"
- name: Setup CommandBox
uses: Ortus-Solutions/setup-commandbox@main
- name: Install dependencies
run: box install
- name: Start server
run: box server start cfengine=lucee@5.3 --noSaveSettings
- name: Run TestBox Tests
run: box testbox run reporter=text
Lisa
04/17/2023, 6:27 PMbdw429s
04/17/2023, 6:41 PM--verbose
to your box install
and review the console output to ensure the correct version of cbsecurity was installed to the location you expect.bdw429s
04/17/2023, 6:41 PMUserServiceTest.cfc
extending the coldbox base integration test class?bdw429s
04/17/2023, 6:41 PMLisa
04/17/2023, 9:13 PMLisa
04/17/2023, 9:16 PMUserServiceTest
is extending coldbox BaseTestCaseLisa
04/17/2023, 11:20 PMInstalling to: /home/runner/work/my-emc/my-emc/coldbox
Note: double my-emcbdw429s
04/17/2023, 11:20 PMbdw429s
04/17/2023, 11:21 PMLisa
04/17/2023, 11:21 PMbdw429s
04/17/2023, 11:21 PMbdw429s
04/17/2023, 11:21 PMbdw429s
04/17/2023, 11:22 PMbox.json
that's overriding the install paths (bullet #2)Lisa
04/17/2023, 11:22 PMLisa
04/17/2023, 11:22 PMLisa
04/18/2023, 7:36 PMmy-emc
?
As a command line option or custom box.json?bdw429s
04/18/2023, 7:36 PMbdw429s
04/18/2023, 7:36 PMbdw429s
04/18/2023, 7:37 PMbox install
runs from the root of the app-- wherever that may be, the installation paths are all relative.Lisa
04/20/2023, 8:34 PMError: Requested instance not found: 'authenticationService@cbauth' The instance could not be located in any declared scan location(s) (tests.models) or full path location or parent or children
Our WireBox.cfc has:
scanLocations : [ "models", "services", "/www/modules/cbsecurity/models/", "/www/modules/cbsecurity/modules/cbauth/models/", "/www/services/" ]
and
map( "authenticationService@cbauth" ).to( "www.modules.cbsecurity.modules.cbauth.models.AuthenticationService" );
which is working for cbsecurity but NOT authenticationService@cbauthLisa
04/20/2023, 8:36 PMbdw429s
04/21/2023, 2:23 PMbdw429s
04/21/2023, 2:24 PMmodels
is already the default scan locations for wirebox inside of a coldbox app. Secondly, there's really no need to be manually pointing scan locations to a module's files. As part of the module registration, WireBox will just automatically and recursively map the module's entire models folder so everything should "just work".bdw429s
04/21/2023, 2:25 PMbdw429s
04/21/2023, 2:25 PMbdw429s
04/21/2023, 2:29 PM<your-webroot>/models/foo/bar/Baz.cfc
if you are just using the default scan location of /models
the you would need to ask wirebox for Baz like so
getInstance( 'foo.bar.Baz' )
however, if you put this line of code in your /config/WireBox.cfc
...
mapDirectory( 'models' )
then WireBox recursively scans all subdirectories and eagerly creates mappings for every CFC it finds. Now you can just ask WireBox for this
getInstance( 'Baz' )
bdw429s
04/21/2023, 2:32 PMmapDirectory()
on the models folder of that module AND it provides a default suffix, which is the name of the module. So,
.../cbauth/models/AuthenticationService.cfc
creates, by convention, a default WireBox mapping called
<name-of-CFC>@<name-of-module>
which in this case is
authenticationService@cbauth