Copy link to clipboard
Copied
Hi.
I have a large application that is composed of various sub directories.
All of the subdirectories share the same Application.cfc and session, but I'd like to allow each subdirectory to have its own "java_lib" folder with jar files, and to set this.javasettings.loadPaths in each subdirectory/Application.cfc, extending from /Application.cfc and just change its loadPaths.
The actual problem I am having, is that sometimes this work and sometimes I get a java.lang.ClassNotFoundException.
Is it possible to do this, or do I need to restart the application with every loadPaths change?
I understand that I could set all the paths in a single Application.cfc in my root folder, but I'd like to have these subfolders as independant as it could be from each other.
Or perhaps is it possible to call some coldfusion.bootstrap.something method to refresh the class loader?
Hi. Just an update for future googlers.
The issue was intermittent and I was unable to identify when it worked and when it did not.
I ended up copying the JAR to CFHOME/lib to get rid of the problem.
Not having the source code of ColdFusion makes it difficult to diagnose the root cause so I gave up on this unfrequent scenario in favor of the more traditional approach.
Thank @Charlie Arehart and @BKBK for your help.
Copy link to clipboard
Copied
That's certainly an interesting question. I'm not at a computer to test things, but I'll share a few thoughts:
Or maybe someone else will respond with a more specific solution or other diagnostic to try. Let us know if you may try what I've proposed.
Copy link to clipboard
Copied
Thanks Charly for your response.
I do not know what else to try, any pointers?
If there were a getMetadata().Reload() or similar method I could try that, but it cannot find anything similar.
I have seen in lucee docs that CreateObject have a third parameter for the JAR file, but it does not work here in Adobe CF.
Copy link to clipboard
Copied
All very interesting to hear, and understandable that it's a curious problem. Again, perhaps others will have more to share as answers. For now, I have still a couple more questions to try to help diagnose the situation.
So about what you are setting as that loadpath, you say in this last reply that "I am setting [...] my loadpaths to my single directory "D:\ColdFusion2021\sandbox\wwwroot\asp\package\java_lib"". First, can you confirm you are setting that as a hard-coded string? Or is the path being set from a variable? If the latter, are you dumping the value of that variable in your try/catch?
Second, you had said originally that "I'd like to allow each subdirectory to have its own "java_lib" folder with jar files, and to set this.javasettings.loadPaths in each subdirectory/Application.cfc". Given the path you show, D:\ColdFusion2021\sandbox\wwwroot\asp\package\java_lib, does that mean that this app is using that asp folder and some other app would use a different subfolder of that wwwroot? Of course it's not important WHAT the folder is, and this may not be germaine to the problem. I'm just connecting dots, as we try to understand your issue.
Finally, yes, while Lucee adds a feature on createobect/cfobject to name the library path from which to load that specific class, CF has not yet adopted that. We have only this app-level setting, for now (added in CF10).
I doubt more than a couple percent of CF (or Lucee) users do their own loading of java classes--or with an interest in controlling that at an app (as both CF and Lucee offer) or at the template level (as Lucee offers). I mention this both to propose why CF has not yet adopted that last feature.
But it also explains why there's no means in CFML (I know of) to do the reload you seek, and why there would be few people who would know of this problem and how to solve it.
If you don't get anywhere here, you may want to open a bug in tracker.adobe.com (Adobe folks respond in SOME forum threads here, but not most). You might also want to broaden your reach to the CFML Slack, the Facebook CF Programmers Group, and elsewhere, as there are fans of each who are active only there and not here. I list links for those in a catagory of my cf411 page, specifically at https://cf411.com/cfcommhelp.
If you may get a solution somewhere, I hope you may come back and update this thread here.
Copy link to clipboard
Copied
Hi. Just an update for future googlers.
The issue was intermittent and I was unable to identify when it worked and when it did not.
I ended up copying the JAR to CFHOME/lib to get rid of the problem.
Not having the source code of ColdFusion makes it difficult to diagnose the root cause so I gave up on this unfrequent scenario in favor of the more traditional approach.
Thank @Charlie Arehart and @BKBK for your help.
Copy link to clipboard
Copied
Curious issue.
Before we move on, I should like to mention something I wondered about that might relate to the intermittency of the issue. What if there are occasions when the subdirectory's CFC incorrectly inherits or even fails to inherit from the root Application.cfc? For example, ColdFusion may be following different possible paths when searching up the folders in the inheritance tree. I say this because D:\ColdFusion2021\sandbox\wwwroot doesn't look like the default web root.
Try the following to avoid inconsistency:
component extends="workspace.CF_Project.Application" {
this.name = "ormSubApp";
}
this.javaSettings = {LoadPaths = ["D:\ColdFusion2021\sandbox\wwwroot\asp\package\java_lib\"], loadColdFusionClassPath = true, reloadOnChange= "true", watchInterval=5};​
Copy link to clipboard
Copied
Yes, you can set