RE: [coldbox:16565] Problems with Model and Injections

Services are typically singletons, which means that only one of them exists for the entire application, and they don’t store any instance data specific to a given user. You have named this CFC as a service, but you seem to be treating it as a transient. If you want it to be a singleton, then just place the “singleton” annotation in the component declaration and don’t worry about creating or persisting it-- WireBox will do that for you.

component singleton {
}

If you are intending this CFC to be specific to a single user and contain unique data about that user and you actually want it in the session scope, I would recommend taking Service out of the name, and use the scope=“session” annotation to let WireBox automatically handle the session-scoped persistence.

component scope=“session” {
}

The one thing you haven’t shown is us how you are getting a reference to the CFC. Are you using createObject() to create it (bad) or asking WireBox for it (good).

Asking WireBox for it could look like this (good for transients):
getModel(“User”);

Or wiring the reference into your handler:
property name=“userService” inject;
ONLY do this if your userService is a singleton, or you will suffer from scope widening injection.

Also, a couple random notes, only event handlers (in the your handlers directory) should extend the event handler ColdBox core file. Only WireBox binder configs (in your config directory) should extend the binder ColdBox core file.
Your CFC only needs to extend another CFC if you are trying to use ORM services functionality from ColdBox (like Andrew suggested) or if your application design has some common base object you want to inherit from.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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