How do I inject libraries into a non-ORM object?
This is how I instantiate the obj:
obj1 = wirebox.getInstance(“Class1”);
In Wirebox.cfc I have:
map(“lib1”).to(“lib.lib1”).asSingleton();
In Class1.cfc I have:
but when I try to use lib1 in any of the methods in Class1 I get:
Element LIB1 is undefined in a Java object of type class…
Nick,
I cannot see anything immediately wrong with the way you doing it. I quick spun a server to test it and all works fine. See code below.
/lib/Lib1.cfc
component singleton {
function foo(){
return “bar”;
}
}
/models/Class1.cfc
component {
property name=“lib1” inject=“Lib1”;
function myMethod(){
return lib1.foo();
}
}
/handlers/Main.cfc
component extends=“coldbox.system.EventHandler”{
// Default Action
function index(event,rc,prc){
obj1 = wirebox.getInstance(“Class1”);
return obj1.myMethod();
}
//…other handlers and actions
}
/config/wirebox.cfc
map(“lib1”).to(“lib.lib1”);
As a side note, if you add the ‘singleton’ attribute to the component declaration (such as a bove) wirebox will automagically instantiate the object as a singleton ! 
Thanks for your help.
Turns out the path for the scanLocations wasn’t correct. I forgot to add the base folder (my site is under a subfolder).