I’m getting “undefined” errors trying access injected variable in the postLoad or init function of an entity. But the variable is accessible once the entity is instantiated.
My Wirebox.cfc that maps a variable called “workflowDefinitions” for injection.
map("workflowDefinitions").toValue(xmlParse(getDirectoryFromPath(getTemplatePath()) & "config\workflows.xml")).asSingleton();
And the entity (Programme.cfc) that’s injected with “workflowDefinitions”:
`
`
error 1 = Error building: programmeService -> Element WORKFLOWDEFINITIONS is undefined in VARIABLES. with constructor arguments: {}
error 2 = coldfusion.runtime.UndefinedElementException: Element WORKFLOWDEFINITIONS is undefined in VARIABLES. Root cause :org.hibernate.HibernateException: coldfusion.runtime.UndefinedElementException: Element WORKFLOWDEFINITIONS is undefined in VARIABLES.
and the controller code
prog = programmeService.get(1); writeDump(prog.getWorkflow()); // this works
and finally the ProgrammeService.cfc:
<cfcomponent extends="coldbox.system.modules.cborm.models.VirtualEntityService"> <cffunction name="init"> <cfscript> super.init(entityName="Programme", useQueryCaching=true, defaultAsQuery=false); return this; </cfscript> </cffunction> </cfcomponent>