Created attachment 39612 [details] reproducer web application I PROVIDED A SAMLE REPRODUCER WEB APPLICATION: Simply unzip and run it. Additionally, I have provided more detailed descriptions and explanations in the "HELP.md" file. ************************************************************************************** DESCRIPTION OF THE BUG: Some implementations of ClassFileTransformer may lead to WebappClassLoaderBase performing duplicate class definitions. If a ClassFileTransformer triggers the loading of a class that is currently in the process of being loaded by WebappClassLoaderBase, it leads to the following error: " java.lang.LinkageError: loader org.apache.catalina.loader.ParallelWebappClassLoader @1d562d1a attempted duplicate class definition for reproducer.webappclassloaderbug.SomeClass." The chain of execution looks like this: loadClass (SomeClass) -> findClassInternal (SomeClass) -> transform (SomeClass) -> loadClass (SomeClass) -> findClassInternal (SomeClass) -> defineClass (SomeClass) The issue arises when SomeClass is defined during the innermost (second) invocation of the findClassInternal method. Upon returning to the outermost (first) call of findClassInternal within this method, another invocation of defineClass occurs, resulting in an error. Ideally, this attempt to duplicate class definition should be avoided, as the class is already defined. ************************************************************************************** REAL-WORLD EXAMPLE: This error happened in a real-world application. In this case the ClassFileTransformer (or rather code excecuted inside the transformer) is the eclipse link load time weaver (org.eclipse.persistence.internal.jpa.weaving.PersistenceWeaver). The conditions for triggering this bug are intricate. If needed, I can furnish additional details about it.
Thanks for the test case. It made it very easy to confirm both the bug and the fix. This has been fixed in: - 11.0.x for 11.0.0-M18 onwards - 10.1.x for 10.1.20 onwards - 9.0.x for 9.0.87 onwards - 8.5.x for 8.5.100 onwards