Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-834

ThrowableProxy throws NoClassDefFoundError

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.2
    • Component/s: None
    • Labels:
      None

      Description

      In method loadClass we expect ClassNotFoundException. But if class comes from another java machine we can get NoClassDefFoundError.

      Possible fix:

      private Class<?> loadClass(final ClassLoader lastLoader, final String className) {
             // XXX: this is overly complicated
             Class<?> clazz;
             if (lastLoader != null) {
                 try {
                     clazz = Loader.initializeClass(className, lastLoader);
                     if (clazz != null) {
                         return clazz;
                     }
                 } catch (final Throwable ignore) {
                     // Ignore exception.
                 }
             }
             try {
                 clazz = Loader.loadClass(className);
             } catch (final ClassNotFoundException | LinkageError ignored) {
                 try {
                     clazz = Loader.initializeClass(className, this.getClass().getClassLoader());
                 } catch (final ClassNotFoundException | LinkageError ignore) {
                     return null;
                 }
             }
             return clazz;
         }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                garydgregory Gary Gregory
                Reporter:
                ndkoval Nikita Koval
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: