|
| Description: |
I don't have reproduction steps, I've just encountered it randomly after downgrading/upgrading [Formula macro|https://extensions.xwiki.org/xwiki/bin/view/Extension/Formula%20Macro/] on demo XWiki Jetty/HSQLDB.
Where instead of rendered macro, I have stacktrace {noformat} Failed to execute the [formula] macro error . Cause: [ Exception java ^full stack trace . lang.ClassCastException: class net.sourceforge.jeuclid.converter.ImageIODetector cannot be cast to class net.sourceforge.jeuclid.converter.ConverterDetector (net.sourceforge.jeuclid.converter.ImageIODetector is in unnamed module of loader 'wiki:xwiki'; net.sourceforge.jeuclid.converter.ConverterDetector is in unnamed module of loader 'wiki:xwiki') [in thread http://localhost:8080/xwiki/bin/view/Sandbox/TestPage1 txt ] ]. java.lang.NoClassDefFoundError: Could not initialize class net.sourceforge.jeuclid.converter.ConverterRegistry$SingletonHolder ..... Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.ClassCastException: class net.sourceforge.jeuclid.converter.ImageIODetector cannot be cast to class net.sourceforge.jeuclid.converter.ConverterDetector (net.sourceforge.jeuclid.converter.ImageIODetector is in unnamed module of loader 'wiki:xwiki'; net.sourceforge.jeuclid.converter.ConverterDetector is in unnamed module of loader 'wiki:xwiki') [in thread http://localhost:8080/xwiki/bin/view/Sandbox/TestPage1] .... {noformat}
Restarting XWiki resolves the issue.
Thanks [~MichaelHamann] for findings and below details
A classloader conflict can occur after installing, upgrading, or removing JAR-based extensions without a full XWiki restart.
Root cause appears to be {{org.apache.xmlgraphics.util.Service}} (loaded from the XWiki WAR via xwiki-platform-oldcore), which maintains an internal static cache of discovered service implementations. Since this class comes from the WAR, it is not reloaded when extension classloaders are refreshed.
If a service implementation originating from an extension JAR (e.g. {{net.sourceforge.jeuclid.converter.ImageIODetector}}) is cached there, the cache may retain an instance tied to the old extension classloader after extension reload.
Subsequent code execution then attempts to use the cached old instance together with classes loaded from the new extension classloader, causing class identity mismatch errors such as:
{noformat} java.lang.ClassCastException: net.sourceforge.jeuclid.converter.ImageIODetector cannot be cast to net.sourceforge.jeuclid.converter.ConverterDetector {noformat}
In my case, this breaks JEuclid ConverterRegistry initialization and causes Formula Macro rendering failure: {noformat} java.lang.NoClassDefFoundError: Could not initialize class net.sourceforge.jeuclid.converter.ConverterRegistry {noformat} |
| Attachment: |
full stack trace.txt |
|