In server.json, I'm confused as to what app.libDir...
# box-products
j
In server.json, I'm confused as to what app.libDirs is doing. If I use this.javaSettings, my jar works fine placed into a /jars folder in my project, but if I use app.libDirs then it complains about missing dependencies that are installed in ACF by default (like commons-logging.jar). Is that expected behavior?
b
@John Liljegren
app.libDirs
is essentially the same as dropping a jar in the servlet container's lib folder. It class loads the jar in the same class loader that the CF engine is loaded by.
I'm guessing CF loads commons-logging inside a child class loader, which is not "seen" from the servlet's top level classloader
j
ah ok, that would explain it
b
Classloaders in Java have a parent/child relationship where a CL can ask its parent CL to load a class (recursively) but is not aware of any child CLs
Adobe doesn't really document their classloader hierarchy, but I'm guessing they load the
this.javaSettings
jars in a CL which has visibility to that jar
j
it would be more convenient to just use libDirs instead of javaSettings due to how this project is structured, so that's a bummer, but thanks for the explanation
b
Though, for what it's worth, it's a little sloppy to depend on that jar in the CF core. You can add your own version of commons-logging alongside your custom jar. Just keep in mind, if you include a different version of commons-logging as ACF uses, that may also cause different errors. Welcome to java classloader hell 🙂
So if you want to use server.json, then just try putting a copy of the logging jar there as well.
j
yeah won't be going down that route... again it's all due to how this project is structured and trying to bring it to the 21st century
thanks for your help, as always!
👍 1