https://bz.apache.org/bugzilla/show_bug.cgi?id=68721

            Bug ID: 68721
           Summary: WebappClassLoaderBase fails with duplicate class
                    definition
           Product: Tomcat 10
           Version: 10.1.18
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: jonatan.sch...@mgm-tp.com
  Target Milestone: ------

Created attachment 39612
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=39612&action=edit
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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to