Commandbox vs. Application.cfc question... is ther...
# box-products
p
Commandbox vs. Application.cfc question... is there a better/best practice for incorporating an external library
jar
into a CF app? In particular, I see two methods: 1) set
web.libDirs
in Commandbox for the server, or set
this.javaSettings
in Application.cfc. Is there a difference? I just need to be able to add in a particular JDBC .jar file.
s
Pretty sure the end result is basically the same - the libs are available to your application code. I think whether to use one or the other is simply determined by which part of the stack you want to loop in the dependency.
web.libDirs
pulls them in during server instance start, whereas
this.javaSettings
brings them in when the application starts (or on each request? - I'm not actually sure what kind of overhead using this adds to the application - for that reason it might be more optimal to use
web.libDirs
).
Of course, if you want the application to be portable to non-Commandbox deployments,
this.javaSettings
would be the way to go.
p
Right - that makes sense. Thanks.
b
@seandaniels @Peter Hoopes It's
app.libDirs
, not
web.libDirs
šŸ™‚
šŸ‘ 1
The only time you'd NEED the libdirs is if you had • JDBC jars required by CF engine • contributing Java classes to Undertow • any other sort of low level class used by the servlet The libdirs are added to the system classloader that is the top level CL for the entire server process so those jars are "visible" to everything.
this.javaSettings
are loaded by a classloader inside of the CF engine, which is normally just fine if you only need to access those classes in your CFML code.
šŸ‘ 1
p
This is a JDBC jar that I need to load, but it's not used by any other application on that server instance, and it's not used by Lucee for session storage or the like. So I would imagine it's OK in either location?
b
What exactly is it used for??
If you're using it to create a datasource connection, then you can try it this.javasettings, but I wouldn't expect that to work. That code never even runs until after the first request comes into the server, which is long after your server's datasources have been loaded in the admin!
I also explicitly listed JDBC jars in my list of scenarios where libdirs would be requried
• JDBC jars required by CF engine
So I'm unclear where you would then get the idea that either place would work šŸ™ƒ
@Peter Hoopes
p
I guess I was trying to decipher between the needs of the CF engine and the CF application itself. It's in the right place and working, so I think we're all good. Thanks!