0

Anyone have any idea on how to fix this?

"Unable to invoke CFC - The value returned from the getAllContacts function is not of type Contacts[].

If the component name is specified as a return type, it is possible that either a definition file for the component cannot be found or is not accessible."

Thank You.

[UPDATE]

Sure thing: Here's the code within ContactsService.cfc:

<cfcomponent output="false">

    <!--- [irrelevant code removed] --->

    <cffunction name="getAllContacts" returntype="Contacts[]" access="remote">
        <cfreturn entityload("Contacts") />
    </cffunction>

    <!--- [irrelevant code removed] --->

     And code within Contacts.cfc:

<cfcomponent persistent="true" table="Contacts"  output="false">
    <cfproperty name="id" column="id" type="numeric" ormtype="int" fieldtype="id"  /> 
    <cfproperty name="company" column="company" type="string" ormtype="string"  /> 
    <cfproperty name="Sub_Heading" column="Sub_Heading" type="string" ormtype="string"/> 
    <cfproperty name="Department" column="Department" type="numeric" ormtype="int"  /> 
    <cfproperty name="boss" column="boss" type="string" ormtype="string"  /> 
    <cfproperty name="Room" column="Room" type="string" ormtype="string"  /> 
    <cfproperty name="Phone" column="Phone" type="string" ormtype="string"  />  
</cfcomponent>
Community
  • 1
  • 1
jayron
  • 69
  • 7
  • I've taken your code out of my answer and popped it into your question (which is where it belongs). – Adam Cameron Mar 30 '13 at 03:13
  • I'd take the `returntype` away, or just set it as `array` and cal it a day. It is quite demanding for CF to validate if the array contains only of that type. Problem solved. – Henry Mar 30 '13 at 04:45
  • No really "problem solved" @Henry: the code should work as is, so there's definitely something up here, Simply masking the current error will cause the problematic situation to bubble out in the calling code, which is no help to anyone. – Adam Cameron Mar 30 '13 at 21:34
  • @AdamCameron I agree, however getting rid of that returntype problem will illustrate to the author the real problem behind it, which mostly likely because it's an empty array with 0 entity found. – Henry Mar 31 '13 at 08:52

1 Answers1

1

You've not giving us much to go on! About as much as one can say is "the error message explains very clearly what's probably wrong". If you post some code, then we can give you a better idea.

But basically your method is expecting to return an array of Contact objects, but that's not what you're trying to return.

If you expand your question to contain enough info to answer properly, I'll update the answer to be more thorough...

Update 1 I still cannot answer your question, but I can build on this answer a bit.

It looks to me like your entityLoad() is not actually finding anything. Do you have any Contacts stored?

Can you change your method to be like this:

<cffunction name="getAllContacts" returntype="ANY" access="remote">
    <cfset var allContacts = entityload("Contacts")>
    <cfdump var="#allContacts#">
    <cfreturn allContacts>
</cffunction>

And then call the method and see what it outputs. This should give you a clue.

[TO BE CONTINUED... if you're a StackOverflow policeman, please leave this be. I know it's not a full answer yet, but by the time we get to the bottom of this it will be. I know what I'm doing]

Adam Cameron
  • 29,677
  • 4
  • 37
  • 78
  • Thank you! But unfortunately the plot thickens. Now Contact.cfc and ContactsService.cfc can no longer be in the same directory?? Dreamweaver can be such a brat sometimes. I probably have done something sloppy and caused some concurrency issues. I'm only guessing this point. – jayron Mar 30 '13 at 22:11
  • What has DreamWeaver got to do with this? Clearly it's the text editor you're using, but is it DW telling you you cannot have the CFCs in the same dir, or are you getting a CF error? I'd just ignore stupid message DW gives you, TBH. – Adam Cameron Mar 31 '13 at 01:37
  • So yo're sorted now, and this becomes a bit of a non-question? If so, can you delete it? – Adam Cameron Apr 05 '13 at 02:59