```Neither the method getDocumentCustomer was foun...
# box-products
c
Copy code
Neither the method getDocumentCustomer was found in component models.reports.sales nor was there any default method with this name present in any of the implementing interface.
b
This sounds like a java error- a stack trace would be really helpful here
c
Copy code
coldfusion.runtime.TemplateProxy$InvalidMethodNameException( Neither the method getDocumentCustomer was found in component models.reports.sales nor was there any default method with this name present in any of the implementing interface.
    at coldfusion.runtime.TemplateProxy.throwInvalidMethodNameException(TemplateProxy.java:1277)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:962)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:696)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:503)
    at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:4254)
    at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:4217)
    at cfsales2ecfc759538788$funcUTILITIES.runFunction(/app/handlers/sales.cfc:700)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:623)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:516)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:463)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:438)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:681)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:980)
    at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:762)
    at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:4165)
    at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:4129)
    at coldfusion.runtime.CFPage.invoke(CFPage.java:16847)
    at cfController2ecfc102072789$funcINVOKER.runFunction(/app/coldbox/system/web/Controller.cfc:1200)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:623)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:516)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:463)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:438)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:681)
    at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:4909)
    at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:4890)
    at cfController2ecfc102072789$func_RUNEVENT.runFunction(/app/coldbox/system/web/Controller.cfc:954)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:623)
    at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:516)
    at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:95)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:463)
    at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:438)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:681)
b
So, based on what you were saying in the other thread, are you not expecting the CFC to be
models.reports.sales
?
c
That's what slack will let me put in, there is more
b
You have to use a "snippet" in slack when you want to paste large text
c
Correct, salesCFC should be models.sales
b
Hit the "plus" button below where you're typing and choose "snippet". There is no limit there
Correct, salesCFC should be models.sales
Ok, so the error message is basically irrelevant then, right? If the wrong CFC is getting injected, let's back up and troubleshoot that, not a downstream error that comes from having the wrong CFC.
What actual CFC are you expecting to get in this case?
c
Ok, I assume I am addressing the file
Copy code
property name="salesCFC" inject="sales";
This should pull in models.sales
b
Do you have two CFC's with the same name in different folders?
because if so, that's your issue
c
Yes
b
You probably got lukcy it ever worked before
You are at the mercy of whatever random order the files are recursively processed off your drive
last one wins!
c
So, do I have to rename it? or is there a work around
b
If you are using the default wirebox conventions here and not creating any custom aliases, you can't really depend on it magically knowing which of the
sales
files you want
As a general rule, I would discourage having multiple files with the same name
But you can also create a custom mapping, or add an alias to the file (requires eager mapping processing to work)
But either way, you need to come up with some way to make them unique so WireBox knows which one you want
c
Is that an issue when I have a handler and a view named the same thing?
b
That's a different kettle of fish entirely. We're talking about WireBox here, which has nothing to do with locating and creating handlers or views
c
Ok. So just within the models folder including subfolders have unique file names.
b
Yes, the default behavior for a long time now is that the models folder is recursively mapped on startup, which is the same as this
Copy code
mapDirectory( 'models' )
So a full list of all files is pulled and
mapPath()
is called on each one of them. mapPath() uses the CFC name as the name of the mapping
So
Copy code
models/foo/bar/baz.cfc
creates a wirebox maping of
baz
c
It's really only within my reports folder I am reusing file names, so it shouldn't be to big of an issue
b
As does
Copy code
models/baz.cfc
models/foo/baz.cfc
and
models/brad/wood/baz.cfc
That's the simplest fix, but just for completness, do you understand what the other two workarounds look like? • custom mapping • alias
c
I haven't used wirebox at all yet
at least in a custom way
b
Would you like me to least show you those two methods so you at least know what the options look like?
c
Please do
b
So if you put this code in your `config/WireBox.cfc`'s
configure()
method
Copy code
map( 'myCustomSalesThingy' ).to( 'models.reports.whatever.sales' );
then you can inject
Copy code
property name="salesCFC" inject="myCustomSalesThingy";
and you get the specific CFC you've asked for.
c
Ah, so similar to routes
b
The alias looks like this and does mostly the same thing. In your sales.cfc component, you add this metadata annotation
Copy code
component alias="myCustomSalesAlias" {
}
And then you inject
Copy code
property name="salesCFC" inject="myCustomSalesAlias";
Basically, the CFC is mapped with the default name, WireBox also adds a mapping for each alias that points to the same CFC
c
That's even better
In the alias could i use
sales.reports
?
I mean
reports.sales
b
I assume so, test it šŸ™‚
Mapping names can basically be whatever you want
The main thing to understand about WireBox is you don't ever technically ask for a CFC directly, you ask for a "mapping" by name or a DSL such as
logbox:logger:foo
and then WireBox goes and figures out what that points to. Most mappings just point to a CFC and most mapping names are the same as the CFC name by convention so the differentiation is sort of invisible at first.
A wirebox mapping can point to anything including a setting, or a static value
One of my favorite debug tips is to dump out
Copy code
wirebox.getBinder().getMappings().keyArray()
and you see all the mapping names wirebox currently knows about (it can create new mappings on the fly too FWIW)
šŸ‘ 1
c
Thanks for all your help. I'm going to fiddle with the wirebox stuff now!
šŸ‘ 1
adding
alias="sales"
to models\sales.cfc does not work. It is still trying to go to models\reports\sales.cfc. I'm going to try the wirebox config next
b
@Cavan Vannice Well, that's because you are still having a conflict of names!
Aliasing a CFC to the same name as the CFC does nothing at all
That's like me telling you to call be "brad" so you don't confuse me with the other "brad"
it only works if the alias is unique
c
Ok, that's fine. I'll rename my files. there are only like 6 of them.
Thanks again