I am building a new module within my project’s modules_apps directory. The new module depends on a module located in an external directory. When I reference the module located in the external location from my new module, it doesn’t exist. I presume this is because modules in the module_apps directory load before externally located modules.
I can call the external module from a handler within the project, but I can’t call it inside the module located in the module_apps directory.
The external module is defined as a dependency inside ModuleConfig.cfc. The external module’s location is also in the project’s Coldbox.cfc file. Is there a way to ensure the external modules load before the project’s module_apps directory loads?
I tried setting up the scenario you’ve outlined and it worked for me. However, there might be a couple “gotchas” that might be causing your problem. I don’t think we’ve met and I don’t know your level of Coldbox experience so if some of these are basic issues, I apologize.
The external module is “myRemoteModule” (just in case that wasn’t clear) and I’m developing the myNewModuleWhichReferencesMyRemoteModule in my Coldbox app. My remote module (remMod.cfc) was a simple:
component {
function runMe(){
writeDump(“This is run me”)
}
}
Make a CFMapping to the myRemoteModuleParent. When Coldbox is scanning for modules, it doesn’t scan the folder it’s pointed to, it scans the folders IN that one and looks for a ModuleConfig.cfc. If you’re using cfconfig, here is the CFMappings node I used:
Thank you, Dan,
I reproduced your example, and as you explained, the process works when calling a method from an external module inside a handler. It also works within my project.
However, in my project, I am encountering a different scenario. I am calling a method from an object in the project’s module. Making the call inside the object works in your example but fails in my project.
Therefore, as you pointed out, something else is preventing the module from loading. I am unsure what it is right now, but I appreciate that you responded and gave me some steps to consider for my project. I am still using ColdBox 6.9.0.
As a workaround, I am calling Wirebox from the application scope. application.wirebox.getInstance(‘remMod@remoteMod’). It’s not ideal, but it is the only way I can get it to work for now.
I don’t know whether we met. Many years ago, I was a member of TACFUG, helping to plan the first couple of NCDevCons. I also spoke at the first conference when my former boss, Brian Kotek, couldn’t attend. I haven’t attended any CF conferences since, but my coworkers attend.