I recently installed cbjavaloader using the cli. I believe I followed the instructions:
I placed this in the ColdBox.cfc
javaloader = {
// The array paths to load
loadPaths = getJars( getDirectoryFromPath( getCurrentTemplatePath() ) & “lib” ),
// Load ColdFusion classes with loader
loadColdFusionClassPath = false,
// Attach a custom class loader as a parent
parentClassLoader = “”,
// Directories that contain Java source code that are to be dynamically compiled
sourceDirectories = [],
// the directory to build the .jar file for dynamic compilation in, defaults to ./tmp
compileDirectory = getDirectoryFromPath( getCurrentTemplatePath() ) & “model/javaloader/tmp”,
// Whether or not the source is trusted, i.e. it is going to change? Defaults to false, so changes will be recompiled and loaded
trustedSource = false
};
However now I get this error on app load:# Variable GETJARS is undefined.
The docs for that are wrong. The getJars() helper method is in the ModuleConfig for the module. You will need to build your own array of jars in the ColdBox config.
Is there any documentation/procedures on how we go about handling pull requests for Ortus Solutions?
Also, I attempted to look at the related ticket, however it brought me to a login screen. I attempted to log in with my Google credentials but it did nothing. Are we supposed to ask for permission or is it not supposed to take us to this location or are we allowed to created a new account to see your tickets?
I have a solution, but need to think about where the getJars method should be placed. Right now, I threw it into the Coldbox.cfc just so I was able to get it up and running right away for our needs here.
Would you have a suggestion as to where it should be placed?
Example of how I used it: javaLoader = { loadPaths = getJars(expandPath(’./lib/’))}
Thank you,
Ryan
// JavaLoader settings
/** @hint Get an array of jar/class files. /
private array function getJars(
required string dirPath,
string filter = ".jar,*.class"
) {
if(not directoryExists(arguments.dirPath)) {
throw(message=“Invalid library path”, detail=“The path is #arguments.dirPath#”, type=“JavaLoader.DirectoryNotFoundException”);
}
return directoryList(arguments.dirPath, true, “array”, arguments.filter, “name desc”);
}
javaloader = {
// The array paths to load
loadPaths = getJars(expandPath(’./lib/’)), // The supposed alternative to using getJars() is: [expandPath(’./lib/’) & ‘name_of_jar_file.jar’];
// Load ColdFusion classes with loader
loadColdFusionClassPath = false,
// Attach a custom class loader as a parent
parentClassLoader = “”,
// Directories that contain Java source code that are to be dynamically compiled
sourceDirectories = [],
// the directory to build the .jar file for dynamic compilation in, defaults to ./tmp
compileDirectory = getDirectoryFromPath( getCurrentTemplatePath() ) & “model/javaloader/tmp”,
// Whether or not the source is trusted, i.e. it is going to change? Defaults to false, so changes will be recompiled and loaded
trustedSource = false
};
I’ve just hit this issue converting a site to CB 4.1.0. Seems like the easiest way to specify an array of jars in a folder is to copy the core of the getJars method: