Le 28/05/2016 à 11:57, Taher Alkhateeb a écrit :
Hi Everyone, This is a question for advanced developers. I notice that OFBiz uses a custom class loader called NativeLibClassLoader which extends URLClassLoader from the JDK There is a comment in the class which mentions that the "class is necessary because the bootstrap ClassLoader caches the native library path - so any changes to the library path are ignored (changes that might have been made by loading OFBiz components)" I don't quite understand what is meant by that even after digging into the related classes. It seems like the design is saying that hey, we might load components dynamically and therefore, we will keep their effects in this field -> "CopyOnWriteArrayList<String> libPaths" However, as far as I understand, ofbiz does not load libraries or components dynamically, they either load or not on start, and you cannot call start twice as that would shoot an exception. I guess my question is: Why does ofbiz have a custom ClassLoader? Why bypassing the bootstrapping loader and even then, why not use one of the standard JDK implementations in the ClassLoader hierarchy. I really appreciate your insights on this. Taher Alkhateeb
Hi Taher, As you may know this was introduced by Adrian at http://svn.apache.org/viewvc?view=revision&revision=1676746 for https://issues.apache.org/jira/browse/OFBIZ-6268 after an effort by Jacopo at https://issues.apache.org/jira/browse/OFBIZ-5768 Maybe this was done for something like https://stackoverflow.com/questions/15635039/how-to-handle-shared-native-library-in-multiple-web-applications-on-tomcat where another way of doing it in the Tomcat context is suggested I did not dig further today, but I note this link here for myself http://tomcat.apache.org/tomcat-8.0-doc/class-loader-howto.html Adrian also introduced InstrumentingClassLoader class then. It's related with Cobertura. But as Adrian said he was unable to have it working. HTH Jacques