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 --------
<Datasources>
    <Datasource alias="betaDb" name="betadb" dbtype="oracle"
username="" password="" />
</Datasources >

--------- Model --------
modeltest.cfc
<cfcomponent output="true" autowire="true">
        <cfproperty name="dsn" type="coldbox:datasource:betaDb"
scope="instance"/>

  <cfscript>
    instance = structNew();
  </cfscript>

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

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

  </cffunction>

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

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

Thanks
Kevin

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

Yes.

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: