I have the following flow:
MyComponent.cfc
==============
<cfset variables.javaLoaderVariable =
"7c9a4fe0-5f13-11e0-80e3-0800200c9a66">
<cfset variables.jarLibraryPath = expandPath('/javaloader/lib')>
<cffunction name="initJavaLoader" access="public" returntype="void"
hint="I initialize server scoped JavaLoader.">
<!--- create server scoped JavaLoader instance to prevent JVM memory
leaks --->
<cfset
createObject( 'component','JavaloaderUtils' ).init( variables.javaLoaderVariable,
variables.jarLibraryPath ) >
</cffunction>
JavaLoaderUtils.cfc
===============
<cfcomponent displayname="JavaLoaderUtils"
hint="I encapsulate utility functions that deals with
JavaLoader.">
<cfset variables.serverJavaLoaderVariable = ''>
<cffunction name="init" access="public" returntype="void"
description="I initialize the JavaLoader library into the server
scope of the CF application. This is needed to avoid a known JVM
memory leak">
<cfargument name="serverJavaLoaderVariable" required="true"
type="string"
hint="The name of the server scoped variable to hold the
JavaLoader instance. Must be unique name across server scope.">
<cfargument name="jarLibraryPath" required="false"
default="#expandPath('/javaloader/lib')#"
hint="I store the full directory path value to the location of
all the needed dependency *.jars.">
<cfset var jarPath = ''>
<cfset var aJars = ArrayNew(1)>
<cfset variables.serverJavaLoaderVariable =
arguments.serverJavaLoaderVariable>
<cfif NOT structkeyexists(server,
variables.serverJavaLoaderVariable)>
<cfdirectory action="list" name="qJars"
directory="#arguments.jarLibraryPath#" filter="*.jar" sort="name asc">
<cfloop query="qJars">
<cfscript>
ArrayAppend(aJars, directory & "/" & name);
</cfscript>
</cfloop>
<cflock
name="#variables.serverJavaLoaderVariable#.server.JavaLoader"
throwontimeout="true" timeout="60">
<cfset server[variables.serverJavaLoaderVariable] =
createObject("component",
"javaloader.JavaLoader").init(loadPaths=aJars,
loadColdFusionClassPath=true)>
</cflock>
</cfif>
</cffunction>
</cfcomponent>