I seem to be having a conflict with a java lib whi...
# lucee
d
I seem to be having a conflict with a java lib while using Redis
Copy code
"ERROR","XNIO-1 task-10","06/18/2024","07:44:39","session-storage","org.json.XML;lucee.runtime.exp.NativeException: org.json.XML
	at java.base/java.net.URLClassLoader.findClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at org.apache.felix.framework.BundleWiringImpl.doImplicitBootDelegation(BundleWiringImpl.java:1811)
	at org.apache.felix.framework.BundleWiringImpl.tryImplicitBootDelegation(BundleWiringImpl.java:1740)
	at org.apache.felix.framework.BundleWiringImpl.searchDynamicImports(BundleWiringImpl.java:1693)
	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1569)
	at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1976)
lucee@5.4.6+9 redis.extension-3.0.0.55-SNAPSHOT.lex
The lib mentioned in the stacktrace is used in another component and is loaded into its variables scope, so Im not sure why Redis is trying to use it. Ive also tried loading it into the lucee-server/context/lib folder, but that didnt seem to help. This causes my sessions to fail...
Copy code
18 June 2024 at 07:56 (UTC+10:00)
[INFO ] 18 Jun 2024 07:56:41.647 runwar.context: "DEBUG","XNIO-1 task-7","06/18/2024","07:56:41","scope-context","create new session scope for test/49c06729-47bd-4f1b-bb1d-89bf59d86b24 in cache [sessioncache]"
1e031b4b948b40f88f4b9e6039605e29
lucee
18 June 2024 at 07:56 (UTC+10:00)
[INFO ] 18 Jun 2024 07:56:41.502 runwar.context: "DEBUG","XNIO-1 task-7","06/18/2024","07:56:41","scope-context","load existing data from cache [sessioncache] to create session scope for test/49c06729-47bd-4f1b-bb1d-89bf59d86b24"
1e031b4b948b40f88f4b9e6039605e29
lucee
18 June 2024 at 07:56 (UTC+10:00)
[INFO ] 18 Jun 2024 07:56:41.498 runwar.context: "DEBUG","XNIO-1 task-7","06/18/2024","07:56:41","scope-context","use existing session scope for /49c06729-47bd-4f1b-bb1d-89bf59d86b24 from storage sessioncache"
Thats in reverse order above, it tries to reuse the existing session, attempts to load existing data, throws the error, then creates a new session
l
Professionally supported
d
I would love that, but getting budget for anything right now is near impossible
l
$249 won't break the bank :)
d
We have > 20 containers 😬
FYI πŸ˜‚
l
whatever I can do to help let me know
as long as it solves your problems, we can work something out that's fair
Reported it to the websites team to change the name
oopsy
d
I'll give it a go and see if it solves the immediate problem
Even with the Ortus cache, Im getting errors in the scope log
Copy code
"ERROR","XNIO-1 task-16","06/18/2024","09:16:23","session-storage","org.json.XML;lucee.runtime.exp.NativeException: org.json.XML
	at java.base/java.net.URLClassLoader.findClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
l
Then that might be a core lucee issue
what if you use a ram cache
d
I ended up removing the call to that external jar file, I'll have to work around it in the cfc.
l
I would need to see the code
I don't know what you are trying to do
d
Copy code
variables.xmllib = createObject("java", "org.json.XML", "./json-20230618.jar");
We use that to convert from XML to JSON
l
Ahh, then thi has nothing to do with the caches
or sessions
You have a class loading issues
d
Nah, but whatever Lucee is doing with the sessions, its conflicted by loading that jar
l
Do you have access to
Application.cfc
d
Im embarrased to admit we are still using Application.cfm 😬
l
Ahh, no worries
it is what it is
But just to test
can you add a
this.javaSettings
and try classloading it via the application
you might be able to use the
cfapplication action="update"
to do that as well
At least to test if the issue is focused on the
createobject()
class loading or the Application class loading
d
Yep, I'll have a look tomorrow, Im on AEST and its wine time πŸ˜‰
l
jajajajja
cheers 🍺
just ping me if you need me
glad to help
d
Thanks for your help though πŸ‘ 🍻
d
It sounds like the JAR is part of a component that is being stored in the session scope. I'd recommend avoiding storing components in any data structure you're trying to serialize for something like redis. This can have real performance issues. In a case like this, the deserializer will usually not have knowledge of the class loader that was originally used to load the JAR, thus leading to issues. You're better off just storing the parameters need to recreate the state of the component and then re-creating via a service layer that lazy loads the component.
d
Ah, that's a very interesting concept Dan, I'll try to find some time today to step through the code and see if that component is being stored in the session, or linked to it somehow. I dont think it is, because its a component that is called in a very specific place by only one .cfm file, but with our 20 year old codebase, anything is possible πŸ™‚
I think you nailed it @dswitzer πŸ‘ I moved the java library from
variables
in the
init()
to a
var
inside the function where its needed and Ive not seen the same issues occurring. Will keep an eye on it today. Interesting though, I have no idea how that decided it wanted to be in the session scope 🀷
l
If you put something in
session
scope and you have a distributed cache, then the objects will be serialized and sent over the wire. When they are deserialized back into the requested JVM, they are not guaranteed to have any dependencies inflated that are not serializable. ThatΕ› why putting objects in a serialized cache is discouraged unless you have control of the serialization/deserialization process. If not, try to use a state or memento pattern to basically move the state of an object from one cluster to another
πŸ’― 1
πŸ™ 1