Hi:
Let me take a simple example.
If I use jackson-databind-2.9.7.jar in my project, but SmartFox 2X core current do use jackson-databind-2.8.2.jar.
I deployed jackson-databind-2.9.7.jar in the SFS2X/extensions/__lib__.
I known SmartFox run my App using ClassLoader A, and using ClassLoader B on SmartFox instance. doesn't it?
Is going to be some potential problem?
Thank you. Respect!
Should I care my libraries in SFS2X/extensions/__lib__ are different version with jar SFS2x/lib?
-
- Posts: 13
- Joined: 21 Feb 2018, 03:02
Re: Should I care my libraries in SFS2X/extensions/__lib__ are different version with jar SFS2x/lib?
Hi,
class loading in Java is "parent first", meaning that the current class loader will delegate the loading to its parent class loader (if exists) and, if all else fails, it will try to load from the current class loader.
Because of this, if you want to run different versions of libraries already existing in SFS2X/lib/ it is going to be tricky.
1) If you deploy them in the same jar with your Extension they won't be loaded because the SFS2X version already exist in top class loader, which will load them first.
2) If you deploy them under extensions/__lib__/ you're essentially deploying a different version of a lib in the top classloader which means that "luck" will dictate which one gets seen.
Typically this results in which of the two versions the class loader sees first.
So the actual solution in this scenario would be to replace the SFS2X/lib/ library directly.
You can try to do that and see if everything works the same. Usually it does if the new library doesn't break any previous compatibility.
Hope it's clear.
class loading in Java is "parent first", meaning that the current class loader will delegate the loading to its parent class loader (if exists) and, if all else fails, it will try to load from the current class loader.
Because of this, if you want to run different versions of libraries already existing in SFS2X/lib/ it is going to be tricky.
1) If you deploy them in the same jar with your Extension they won't be loaded because the SFS2X version already exist in top class loader, which will load them first.
2) If you deploy them under extensions/__lib__/ you're essentially deploying a different version of a lib in the top classloader which means that "luck" will dictate which one gets seen.
Typically this results in which of the two versions the class loader sees first.
So the actual solution in this scenario would be to replace the SFS2X/lib/ library directly.
You can try to do that and see if everything works the same. Usually it does if the new library doesn't break any previous compatibility.
Hope it's clear.
Who is online
Users browsing this forum: No registered users and 42 guests