dswitzer
03/15/2022, 12:41 PMlog4j-1.2.17.jar
into a folder that is loaded by the JVM via the classpath. I can run createObject("java", "org.apache.log4j.Logger")
and Lucee will load the JAR.
Now I have another JAR (let's call it Example.jar) being loaded via this.javaSettings
in the Application.cfc
and I have the loadColdFusionClassPath
property set to true
. I can call createObject()
to load classes in Example.jar and it an instance of a class is created.
However, the Example.jar is not able to see the log4j-1.2.17.jar
classes. Any attempts to initiate classes that rely on the Log4j v1 return a huge stacktrace, the root appears to be with a class loader issue:
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:476)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 137 more
If I move Example.jar into the same folder as log4j-1.2.17.jar
then everything works as expected. However, I'm trying to keep Example.jar in a path loaded by this.javaSettings
because it's updated frequently and I want to be able to dynamically reload the JAR.
Why would using Lucee's JavaLoader prevent the class from being found? Should this be working? Am I misunderstanding something?Matt Jones
03/15/2022, 2:12 PMdswitzer
03/15/2022, 2:26 PMbdw429s
03/15/2022, 7:20 PMinto a folder that is loaded by the JVM via the classpath@dswitzer Which folder specifically?
bdw429s
03/15/2022, 7:21 PMbdw429s
03/15/2022, 7:21 PMbdw429s
03/15/2022, 7:22 PMapplication
log in Lucee down to trace (I forget whether you want the server or web context, so try both I guess) and that will add a bunch of logger information for what class loaders are being used.bdw429s
03/15/2022, 7:22 PMdswitzer
03/15/2022, 8:22 PMJavaLoader.cfc
, as it's the only reliable way I could find to resolve the issue across platforms.
What's weird is if I would add the path to the Log4j jar to createObject() call, it would complain because it was finding multiple versions of the same interface.