We are using the shared library Jenkins plugin for our Jenkins code, namely workflow-cps-global-lib.
We implemented workflows successfully on different project types with groovy code in one single shared library.
Today we are encountering an issue which seem class-loading related and I m not sure where the problem lies.
Using an instance of "JAXBContext" in our shared library leads to a classcastexception. I will update later with the exact exception.
The class gets loaded from some other plugin installed on our jenkins.
At some point it was loaded from deployit-plugin (jenkins/plugins/deployit-plugin/web-inf/lib/jaxb-impl-xxx.jar).
After installing xlrelease-plugin (xlrelease-plugin/web-inf/lib/jaxb-impl-xxx.jar), it seems that JAXBContext is now loaded from this plugin and we don't get "ClassCastException" anymore.
There is no direct dependency between the shared library plug-in and those. Our code call methods exposed by those plug-ins tho. My guess for now is that somehow, because we call those plug-ins in our code, we inherit their class path.
If that's the case then how can we have control over which jar version is called? WE tried using grape to grab our version of the jaxb implementation and api but still, the jaxbcontext that was loaded was still the one from xlrelease-plugin.
I looked a bit at the code of workflow-cps-global-lib on github. As expected there's some class loader manipulation.
But I didn't find any pointer to the relations with the class loaders of other plugins.
If I understood correctly what's stated in the Jenkins documentation, when plugin A depends on plugin B, plugin class loader inherits jars from plugin B.
https://jenkins.io/doc/developer/plugin-development/dependencies-and-class-loading/
"workflow-cps-global-lib" does not depend on xlrelease-plugin or deployit-plugin thus should not inherit their class paths.
If anyone has insight as to why I get those classes loaded it in my pipeline exécution it would be very helpful.