Help with autowiring Model file

I have to be doing something wrong, I just can't seem to get
autowiring to work in the Model. I keep getting the variable is
undefined in the scope.

I have the autowire interceptor enabled in the config file

here is the code snippets. (this is just a stripped down version)
----- config --------
    <Datasource alias="betaDb" name="betadb" dbtype="oracle"
username="" password="" />
</Datasources >

--------- Model --------
<cfcomponent output="true" autowire="true">
        <cfproperty name="dsn" type="coldbox:datasource:betaDb"

    instance = structNew();

        <cffunction name="init" returntype="any" >
    <cfreturn this >

       <cffunction name="testDSN" >
    <cfset dsnName = instance.dsn.getName() />
    <cfreturn dsnName />


------ Handler ------
<cfcomponent name="profile" extends="coldbox.system.eventhandler"
output="false" >

  <cffunction name="doTest" access="public" returntype="any"
    <cfargument name="Event" type="coldbox.system.beans.requestContext">
    var objData = CreateObject("component", "model.modeltest").init();
    checktest = objData.testDSN();
    <cfdump var="#checktest#">


Have you reinit’ed your app since you made changes to the model?


I think the problem may be caused by the use of "createObject".
Creating an object manually like that bypasses Coldbox and so the
injections don't fire.

Instead of using createObject, inject your model object into your
handler and your test should work.

- Gabriel

Yup that was it. Thanks. The documentation should make this a little
clearer for us noobs :slight_smile: