[coldbox 3.5.3] referencing plugin in configure() in wirebox.cfc

in configure(), in wirebox.cfc, this throws an error:

writeDump(getColdbox().getPlugin(“utilities”));abort;

the error is:

The mappingExists method was not found.
Either there are no methods with the specified method name and argument types or the mappingExists method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.

The error occurred in C:/inetpub/mrioa/Frameworks/coldbox_3_5_3/system/web/services/PluginService.cfc: line 119

outside of configure, in wirebox.cfc, the same line throws an error. the method getColdbox() DOES exist:

Element COLDBOX is undefined in INSTANCE.

COLUMN 0
ID ??
LINE 92
RAW_TRACE at cfBinder2ecfc443336059$funcGETCOLDBOX.runFunction(C:\inetpub\mrioa\Frameworks\coldbox_3_5_3\system\ioc\config\Binder.cfc:92)
TEMPLATE C:\inetpub\mrioa\Frameworks\coldbox_3_5_3\system\ioc\config\Binder.cfc
TYPE CFML

2
struct
COLUMN 0
ID CF_TEMPLATEPROXY
LINE 13
RAW_TRACE at cfWireBox2ecfc1435345162.runPage(C:\inetpub\mrioa\Applications\API\config\WireBox.cfc:13)
TEMPLATE C:\inetpub\mrioa\Applications\API\config\WireBox.cfc
TYPE CFML

I’m not positive, but you may be trying to use plugins too early in the application lifecycle. ColdBox settings and mappings are one of the first things to boot up when the framework reinitializes Try creating an afterConfigurationLoad interceptor and add your mapping there and see if that works.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

What is the best practice for injecting things into my objects w/o using autowire and, instead, using the binder in wirebox?

What is it you’re trying to inject? If you’re trying to inject a plugin, you should be able to reference it by DSL and not actually create an instance of it when the binder’s config method executes.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

I tried this and its saying the value is null:

.initArg(name=“utilities”,dsl=“coldbox:plugin:utilities”);

I am not using auto wire and need to create the instances when configure() fires.

Can you paste in the exact error message? I’ve never actually used initArg() before, but it should work-- either that or there’s a bug we need to fix.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Sure. Here is the declare:

this.map(“caseBuildService”).to(“API.model.wrapper.case.build.buildService”) .asSingleton()
.noAutoWire()
.setter(name=“javaExecutePath”,value=javaExecutePath)
.setter(name=“trangJarPath”,value=trangJarPath)
.initArg(name=“utilities”,dsl=“coldbox:plugin:utilities”);

In the class, the line that calls getUtilities() throws:

Application Execution ExceptionError Type: Expression : [N/A]

Error Messages: Value must be initialized before use.
Its possible that a method called on a Java object created by CreateObject returned null.

Well, you can create mappings as eager init, but I’ve never actually created instances of my models or plugins inside the actual binder.

Can you elaborate on your requirements for the creation of the object inside the binder’s configure?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

What files does the “getUtilities()” code live in? Can you post that?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Here is the line:

property name=“utilities” inject=“coldbox:plugin:utilities”;

The reason why I need to create instances in the binder is because 2 applications use this model. The first application uses autowire as normal. The second application does not use some modules that this model needs so when autowire happens, errors throw because the dependencies are not available.

The second application is very basic. I am using the relax module and have written a few classes that introspect objects that then write extra information into the documentation for an API I am building.

Here is the line:

property name=“utilities” inject=“coldbox:plugin:utilities”;

The reason why I need to create instances in the binder is because 2 applications use this model. The first application uses autowire as normal. The second application does not use some modules that this model needs so when autowire happens, errors throw because the dependencies are not available.

The second application is very basic. I am using the relax module and have written a few classes that introspect objects that then write extra information into the documentation for an API I am building.