Invalid definition for Property

I am new to Coldbox and I am working my way through the tutorial (60 Minute Quick Start). When I try to add a property to the handler (contacts.cfc) using the code provided:

property name=“contactService” inject=“ContactService”;

I get an error stating that its Invalid definition for Property with this error details:

Property must be defined first within component declaration.

The CFML compiler was processing:

  • A script statement beginning with property on line 40, column 9.

Any help would be appreciated.

Hello. Can you try reiniting the framework and see if it loads after? Also, can you confirm that ContactService.cfc is in your models folder?

Thanks for the reply. I have perform the reinit both ways (via coldbox and the url). Under models there is a ContactService.cfc. I am running Coldbox 5.5.0 and Adobe Coldfusion 2021.0.3. for my local development server if that helps. I feel like I am missing something basic.

Can you post a code snippet of the handler where you define the injection and then the function where you reference it? Thanks.

So it seems to be Coldfusion 2021. I moved the server to Lucee and it worked fine. Is there code different for ColdFusion?

I wouldn’t have thought so for this. Can you try ACF 2018 and see? If it is ACF 2021, you sometimes run into issues of needing certain modules installed, but I am not sure if that is the case here. If ACF 2018 works, you can try installing some of the ACF 2021 modules and let’s see what it might be. CommandBox makes it pretty easy to install them.

I assume the error is telling you what you’ve done wrong. As the error says, the properties must be at the top of the component. I’m betting you’ve placed them farther down under some other code. Share your entire Contacts.cfc source code here and we’ll find out.

Ha…You were absolutely right, Lucee did not care where the property code was but ColdFusion did. I moved it to the very top and everything is now working. Sorry for being such a newbie. Thanks for all the help.

1 Like

No worries, sometimes the solution is staring you in the face. I still don’t know why Adobe is strict and Lucee isn’t, but at least you’re up and running.