Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

this.javaSettings.loadPaths()

Community Beginner ,
Sep 04, 2025 Sep 04, 2025

cf version: CF2023u15, OS: Windows

I have a component "excel.cfc". The component has functions that creates objects of Apache POI classes and use various methods of those POI classes to perform excel manipulation.

ColdFusion's latest POI jar (v5.4.1) isn't compatible with our application. So, I am using an older version (v3.17) of it by placing it in a folder and requesting ColdFusion to load my chosen jar using application.cfc's  this.javaSettings.loadPaths().

When I try to create an object of excel.cfc using createObject(), I see that the poi version that gets loaded is v3.17. This means the setting has worked as it has successfully instructed ColdFusion to make use of the older jars. This is all good.

 

However, if I try to call it using jQuery.post(), like $.post("/shared/cf/excel.cfc?method=func()"), it still ends up loading ColdFusion's v5.4.1 which isn't helpful.

Is there a way I can still instruct ColdFusion to work in this second approach? Maybe, through a setting in my "excel.cfc" perhaps?

282
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 5 Correct answers

Community Expert , Sep 08, 2025 Sep 08, 2025

@skallaje, I think you've identified your problem. You say that the "shared" folder "is present outside of the folder application containing Applicatioin.cfc.: That's key.

 

When you call (what I assume is) a cfm that then invokes the cfc (when then does the call to Java), that cfm request implicitly processes some application.cfc, right? You showed the dump of the getapplicationmetadata., showing the javasettings set, so that HAD to have run one. Is that in /sites/fastweb? 

 

But here's the thi

...
Translate
Community Expert , Sep 08, 2025 Sep 08, 2025

@skallaje,, see what I just wrote above (about this "shared" folder, where you'd replied to me earlier with the same news). I offer there a proposal of the problem andn a solution.

 

And @BKBK, about your code, beware that setting such application settings in a method will not work. They need to be set outside of any method, in the "pseudo constructor". You can use the getapplicationmetadata to prove it: you're change won't be reflected there--and therefore the cfml functionality relying on it w

...
Translate
Community Expert , Sep 09, 2025 Sep 09, 2025
quote

 I called "hello.cfm" from my browser and I noticed that Application.cfc's onCFCRequest() gets fired only if the "test.cfc" is present within the "test" folder because that is where Application.cfc is present. It doesn't get fired if I were to place "test.cfc" within a folder called "shared" outside of "test".

The excel.cfc (mentioned in the original post) is present outside of my application, in a folder called "shared/cf". It is in that folder because 2 other ColdFusion applications make of u

...
Translate
Community Expert , Sep 09, 2025 Sep 09, 2025

Here then is the this.javaSettings test I talked about in my last post:


1.   Confirm default POI version

My environment is ColdFusion 2025 Update 3. Like ColdFusion 2023 Update 15 it has POI 5.4.1.
To confirm this, launch a CFM page containing the code

<cfoutput>#createObject("java", "org.apache.poi.Version").getVersion()#</cfoutput>

The output is: 5.4.1

 

2. Create the test component, excel.cfc

Its location under wwwroot is /shared/cf/excel.cfc (to emulate the path @skallaje had used).

Its code

...
Translate
Community Beginner , Sep 11, 2025 Sep 11, 2025

I think I have my issue resolved. The following is what I just did.

 

-- I created a folder called "_jars" in "shared" folder and moved the POI 3.17 jar to that folder. [It only makes sense since all 3 apps will need the functionality].

-- I created an Application.cfc in the "shared" folder with the following minimal code:

<cfcomponent output="false">
<cfset this.name = "sharedApp" />
<cfset this.javaSettings.loadPaths = [ './_jars' ]>
<cfset this.javaSettings.reloadOnChange = true>
</cfcomponent>

 -

...
Translate
Community Expert ,
Sep 04, 2025 Sep 04, 2025

Well, when you do the successful createobject call, do you name the cfc as being in the same path you use in the jq call, shared/cf/excel?

 

It's when the cfc is called (or a cfm) that Cf looks for an application.cfc (or cfm) in the directory holding that, or it's parent, andnso on until one is found.

 

Ecdn if you think all's correct, since things don't work you need some diagnostics. Use the cf function getapplicationmetadata() to return what properties were (or were not) set per the application.cfc/cfm found by cf when calling that cfc. You could dump it to a file, since your jq call probably expects json or xml rather than the html is dump would output by default. Note that cfdump/writedump has flexibility to send its output to a file, as html or not.

 

Let us know what you find. 


/Charlie (troubleshooter, carehart. org)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 08, 2025 Sep 08, 2025

@Charlie Arehart 
Yes, the path specified in bath of those calls are the same.

getExcel = createObject("component","shared.cf.excel");
 $.post("/shared/cf/excel.cfc?method=func()")

The getApplicationMetaData() returns application.cfc's settings (specified in "this" scope). For the createObject() call, it returns the content shared in the attached jpg whereas in the second call it returns an empty structure which is very odd.

BTW, "shared" is a folder that is present outside of the folder application containing Applicatioin.cfc. And as the name suggests, shared folder's contents are shared by multiple ColdFusion applications.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 08, 2025 Sep 08, 2025
 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2025 Sep 08, 2025

@skallaje, I think you've identified your problem. You say that the "shared" folder "is present outside of the folder application containing Applicatioin.cfc.: That's key.

 

When you call (what I assume is) a cfm that then invokes the cfc (when then does the call to Java), that cfm request implicitly processes some application.cfc, right? You showed the dump of the getapplicationmetadata., showing the javasettings set, so that HAD to have run one. Is that in /sites/fastweb? 

 

But here's the thing :when you call the cfc remotely (whether via jq or just as a url in the browser), that will NOT run the Application.cfc available in that other folder (holding the cfm which called the cfc).

 

Instead, cf will be looking for an Application.cfc in THAT folder, where the cfc lives, or its parent and so on. That's really your solution: create an application.cfc there which holds (at least) the this.javasettings.

 

And if you're worried that this application.cfc could somehow negatively impact calls to cfc's there made from within cfml, no. Cf won't look for or run that "new" app.cfc for such calls to cfcs made from cfml (createobject/cfobject/new/cfinvoke/etc).

 

Let us know if you try it....and even if you say you "wouldn't be able to risk modifying that code base", prove it for yourself with some simple code in another folder. I did--and to be clear, yes, if you have an application.cfc in a folder (or parent) of a cfc you call remotely, that application.cfc Is processed. You really should be able to confirm things for yourself.

 

Let us know how it goes.


/Charlie (troubleshooter, carehart. org)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 05, 2025 Sep 05, 2025

Hi @skallaje , That is quite an interesting problem. The createObject() call is within the application's scope, where you specify the custom v3.17 library to be used. However, it seems like, when the context is an HTTP request, ColdFusion defaults to loading the application's default libraries instead of your custom ones. 

 

If so, then the issue implies that this.javaSettings.loadPaths dictates the class path for components instantiated within the application's scope, like when you use createObject(), but not for components created in an HTTP request using jQuery.post(). ColdFusion might be treating an HTTP request as a new, independent request context. If so, then that would explain why the class loader isn't consistently honoring the this.javaSettings configuration.

 

This hypothesis also suggests a possible workaround. A request like $.post("/shared/cf/excel.cfc?method=func()") will trigger Application.cfc's onCFCRequest eventHandler. So, test by placing the setting this.javaSettings.loadPaths at the beginning of onCFCRequest, for example

<cffunction name="oncfcRequest" returnType="void">
<cfargument type="string" name="cfcname">
<cfargument type="string" name="method">
<cfargument type="struct" name="args">

<cfset this.javaSettings = {LoadPaths = ["/my_POI_lib/poi-bin-3.17.0/"], loadColdFusionClassPath = true, reloadOnChange= "true"}>
 
<!--- etcetera etcetera --->	   
</cffunction>

 

The documentation for javaSettings gives us hints:

loadColdFusionClassPath = a boolean indicating if the default class path should be used, defaults to false;
reloadOnChange = a boolean indicating if the classpaths should be reloaded when they change, the default is false.

It is significant that loadColdFusionClassPath and reloadOnChange are by default False. That tells us that, by default, javaSettings doesn't use ColdFusion's default classpath, and that classpaths are not reloaded when they change. In any case, you could experiment by toggling the value of these attributes between True and False (with and without javaSettings being set in onCFCrequest). 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 08, 2025 Sep 08, 2025

@BKBK 
This is what I just did.
I created a folder called "test".
Added a bare minimum, skeletal "Application.cfc" in it.
Created a "test.cfc" with a method that accepts two arguments.
Added a "hello.cfm" page in it with

<script src="jquery-3.7.1.min.js"></script>
<script>
	$(document).ready(function() {
	$.post("/shared/test.cfc?method=addNumbers",
		{ a: 2, b: 2 },
		function (data) {
			console.log(data);
		}
	);
		});
</script>

 I called "hello.cfm" from my browser and I noticed that Application.cfc's onCFCRequest() gets fired only if the "test.cfc" is present within the "test" folder because that is where Application.cfc is present. It doesn't get fired if I were to place "test.cfc" within a folder called "shared" outside of "test".

The excel.cfc (mentioned in the original post) is present outside of my application, in a folder called "shared/cf". It is in that folder because 2 other ColdFusion applications make of use of shared stuff including excel.cfc from that folder.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2025 Sep 08, 2025

@skallaje,, see what I just wrote above (about this "shared" folder, where you'd replied to me earlier with the same news). I offer there a proposal of the problem andn a solution.

 

And @BKBK, about your code, beware that setting such application settings in a method will not work. They need to be set outside of any method, in the "pseudo constructor". You can use the getapplicationmetadata to prove it: you're change won't be reflected there--and therefore the cfml functionality relying on it would not see it, either.

 

(This catches a lot of folks out, which is the main reason I bring it up, not merely being contrarian.) 

 

And I know you were offering a hypothetical workaround. Again, a simple test should confirm things, if interested. I've even got code that covers both issues here if you guys end up needing it. But it seems you're both close to being able to prove things for yourself. 


/Charlie (troubleshooter, carehart. org)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2025 Sep 09, 2025

@Charlie Arehart , Thanks for the remark. I don't consider it being contrarian at all. In fact, you are right.

It is a ColdFusion 101 that bears emphasizing: on any day, in any case, application variables, such as this.javaSettings, should be defined in the pseudo-constructor section of Application.cfc.

 

Nevertheless, I was just offering a hypothetical workaround to be tested. The reported issue is a strange one, hence the strange suggestion. Anyway, you confirm you realize that, which is reassuring.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2025 Sep 09, 2025
quote

 I called "hello.cfm" from my browser and I noticed that Application.cfc's onCFCRequest() gets fired only if the "test.cfc" is present within the "test" folder because that is where Application.cfc is present. It doesn't get fired if I were to place "test.cfc" within a folder called "shared" outside of "test".

The excel.cfc (mentioned in the original post) is present outside of my application, in a folder called "shared/cf". It is in that folder because 2 other ColdFusion applications make of use of shared stuff including excel.cfc from that folder.


By @skallaje

 

@skallaje , I think you've got us barking up the wrong tree. There are no issues with ColdFusion's this.javaSettings. I shall demonstrate it conclusively in a moment. It means that the issue you're facing is the result of a mistake in your paths, settings or code.

 

The first likely mistake could be in your paths. You say, "The excel.cfc (mentioned in the original post) is present outside of my application." This statement contains a clue. Your application is essentially defined by its Application.cfc file. If excel.cfc is outside the application, it won't be able to "see" the this.javaSettings in Application.cfc.

 

From your original description, I had taken it for granted that the Application.cfc file containing the this.javaSettings code is in the same directory as the component excel.cfc. That is, in your cf directory. So, you should place it -- or move it -- there. Alternatively, place it one directory up, in /shared.

 

The second likely mistake could be in your code. You write, "I created a folder called "test".
Added a bare minimum, skeletal "Application.cfc" in it.". Does the "test" folder include the directory /shared? That is not clear from your test-request,

$.post("/shared/test.cfc?method=addNumbers"

Also, could you share the code of the skeletal Application.cfc? 

 

I shall provide in the next post a test involving ColdFusion's this.javaSettings. The test is constructed to be as close to your scenario as possible. It shows that, in spite of what we at first thought, ColdFusion's this.javaSettings actually works as expected. That is:

  •  When the context is an HTTP CFC request, ColdFusion does not default to loading the application's default libraries. It will load your custom libraries instead, if the requested CFC has access to the Application.cfc that defines this.javaSettings.
  • ColdFusion does not treat an HTTP request as a new, independent request context. It treats it as it would any internal createObject() instantiation. The key is that the class loader will honour the this.javaSettings configuration of the Application.cfc file that is in effect. 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2025 Sep 09, 2025

Here then is the this.javaSettings test I talked about in my last post:


1.   Confirm default POI version

My environment is ColdFusion 2025 Update 3. Like ColdFusion 2023 Update 15 it has POI 5.4.1.
To confirm this, launch a CFM page containing the code

<cfoutput>#createObject("java", "org.apache.poi.Version").getVersion()#</cfoutput>

The output is: 5.4.1

 

2. Create the test component, excel.cfc

Its location under wwwroot is /shared/cf/excel.cfc (to emulate the path @skallaje had used).

Its code is

<cfcomponent>
	<cffunction name="getPOIversion" returntype="string" output="false">
			
		<cfset var version = createObject(  "java", "org.apache.poi.Version").getVersion()>
		
		<cfreturn "The POI version is " & version>
		
	</cffunction>

</cfcomponent>

 

3. Download POI 3.17 libraries and deploy them for testing

Go to the POI library archive and download the file poi-bin-3.17-20170915.zip.

Unpack it and you'll get the folder poi-3.17.

Create the new directory my_POI_library directly under wwwroot. Copy or move the folder poi-3.17 into my_POI_library.

 

4. Create the Application.cfc containing the appropriate this.javaSettings configuration

The file Application.cfc is to be located in /shared/cf/.

Its code is:

<!---
This is the Application.cfc file for a ColdFusion application.
It defines application-wide settings and event handlers.
--->
<cfcomponent>

    <!--- Application-wide settings, defined in the THIS scope. --->
    <cfset this.name = "MyCFApplication">
    <cfset this.sessionManagement = true>
    <cfset this.sessionTimeout = createTimeSpan(0, 0, 30, 0)>
    <cfset this.applicationTimeout = createTimeSpan(1, 0, 0, 0)>
	<cfset this.javaSettings = {loadPaths = ["\my_POI_library\poi-3.17\"], loadColdFusionClassPath = true, reloadOnChange= true}>


    <cffunction name="onApplicationStart" returntype="boolean">

        <cfreturn true>
    </cffunction>

    <cffunction name="onSessionStart">
       
    </cffunction>

    <cffunction name="onRequestStart">
        <cfargument name="thePage" required="true">
		
		 <cfreturn true>
    </cffunction>
	
	<cffunction name="oncfcRequest" returnType="string">
		<cfargument type="string" name="cfcName">
		<cfargument type="string" name="method">
		<cfargument type="struct" name="args">


		<cfinvoke
			returnvariable="local.version"
			component="#arguments.cfcName#"
			method="#arguments.method#">

		<cfreturn local.version>
	   
	</cffunction>


    <cffunction name="onRequestEnd">
        <cfargument name="thePage" required="true">

    </cffunction>

    <cffunction name="onApplicationEnd">
        <cfargument name="applicationScope" required="true">

    </cffunction>

    <cffunction name="onSessionEnd">
        <cfargument name="sessionScope" required="true">
	<cfargument name="applicationScope" required="true">

    </cffunction>

</cfcomponent>

5. Restart ColdFusion.

 

6.  Make an HTTP request to the getPOIversion method of excel.cfc
In my test, I simply make the request by launching http://127.0.0.1:8500/shared/cf/excel.cfc?method=getPOIversion in a browser.

 

The output: The POI version is 3.17

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 11, 2025 Sep 11, 2025

I think I have my issue resolved. The following is what I just did.

 

-- I created a folder called "_jars" in "shared" folder and moved the POI 3.17 jar to that folder. [It only makes sense since all 3 apps will need the functionality].

-- I created an Application.cfc in the "shared" folder with the following minimal code:

<cfcomponent output="false">
<cfset this.name = "sharedApp" />
<cfset this.javaSettings.loadPaths = [ './_jars' ]>
<cfset this.javaSettings.reloadOnChange = true>
</cfcomponent>

 -- In my application's Application.cfc file, I prepended that newly created jar folder path to the this.javaSettings.loadPaths array:

this.javaSettings.loadPaths = [ '/shared/_jars', './_classes' ];
this.javaSettings.reloadOnChange = true;

-- Restarted the ColdFusion server.

It looks like everything is working as expected. @Charlie Arehart , @BKBK thank you very much in helping me get this fixed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2025 Sep 11, 2025
LATEST

@skallaje , I am glad to hear that the issue is resolved. Happy coding!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources