On 07/06/2024 09:04, Jeroen Hoffman wrote:
On 06-Jun-24 18:17, Mark Thomas wrote:
On 06/06/2024 11:01, Jeroen Hoffman wrote:
Hi all,
We've found a side effect of change #68721 [1] in Tomcat 10.1.20 that
we'd like to notify you about.
We're using Apache Freemarker for back-end templating, and its
NodeModel class uses reflection to determine what classes to use for
xpath, thereby catching IllegalAccessError, see [2].
Per change #68721 a IllegalAccessError is caught as LinkageError and
turned into a Throwable, NoClassDefFoundError in our case, see [3],
and then falls through that block in NodeModel and errors out.
So this change in Tomcat alters the behaviour in Freemarker, which I
assume was unexpected. We can (and must) work around it, preventing
the IllegalAccessError, but still, maybe you'd like to improve again
or have other thoughts?
How are you getting from the original IllegalAccessError to a
NoClassDefFoundError? Tomcat should re-throw the original
IllegalAccessError.
Small correction from my side: WebappClassLoaderBase throws a
ClassNotFoundException (not NoClassDefFoundError) at the end of
#loadClass (line 1353).
It's not re-throwing the original IllegalAccessError because the call to
#findLoadedClass0(name) at line 2361 is NOT throwing anything, just
returns null and then the ClassNotFoundException is thrown.
This specific case is about an anonymous inner class that implements
PrefixResolver from the java.xml module, see
https://github.com/apache/freemarker/blob/2.3/freemarker-core/src/main/java/freemarker/ext/dom/SunInternalXalanXPathSupport.java
Got it. Thanks for the explanation.
I need to confirm that it doesn't break the original fix but my plan is
to check clazz after line 2311 and rethrow the original exception if it
is null.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org