OpenWebBeans
  1. OpenWebBeans
  2. OWB-468

Make BeansDeployer.deployFromClassPath(ScannerService) resilient to ClassNotFoundException and NoClassDefFoundError's

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 1.0.0-alpha-2, 1.0.0, 1.0.1, 1.1.0
    • Fix Version/s: 1.2.0
    • Labels:
      None
    • Environment:
      Windows Server 2003

      Description

      In tiered classloading environments, lifecycle start --> BeansDeployer deploy --> AnnotatedElementFactory.newAnnotatedType(Class<X>) sometimes throws ClassNotFoundException and NoClassDefFoundError's from the following methods
      Field[] fields = SecurityUtil.doPrivilegedGetDeclaredFields(annotatedClass);
      Method[] methods = SecurityUtil.doPrivilegedGetDeclaredMethods(annotatedClass);
      These exceptions and errors are typically due to incorrect or erroneous application packaging of classes and dependencies.

      I would like OpenWebBeans to continue loading other classes even if one/few classes cannot be loaded correctly i.e. the assumption is that we don't punish the majority for the crimes of a few. We define Managed Beans ONLY for classes that yield a AnnotatedType.

      At runtime, if the application exercises any CDI function on the "bad" classes, then the results are indeterminate.
      I will attach a patch that will explain my approach of fixing this.

      java.lang.NoClassDefFoundError: com.example svt.acme.AnnuityMgmt
      at java.lang.ClassLoader.defineClassImpl(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:260)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:69)
      at com.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:803)
      at com.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:718)
      at com.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:541)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:612)
      at com.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:539)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:612)
      at java.lang.Class.getDeclaredMethodsImpl(Native Method)
      at java.lang.Class.getDeclaredMethods(Class.java:674)
      at org.apache.webbeans.util.SecurityUtil$PrivilegedActionForClass.run(SecurityUtil.java:137)
      at java.security.AccessController.doPrivileged(AccessController.java:203)
      at org.apache.webbeans.util.SecurityUtil.doPrivilegedGetDeclaredMethods(SecurityUtil.java:84)
      at org.apache.webbeans.portable.AnnotatedElementFactory.newAnnotatedType(AnnotatedElementFactory.java:102)

      1. owb-468.patch
        9 kB
        Rohit Dilip Kelapure

        Issue Links

          Activity

          Hide
          Mark Struberg added a comment -

          duplicates OWB-475

          Show
          Mark Struberg added a comment - duplicates OWB-475
          Hide
          Mark Struberg added a comment -

          moved to target-1.2.0

          Show
          Mark Struberg added a comment - moved to target-1.2.0
          Hide
          Mark Struberg added a comment -

          Rohit, is this fixed now? - txs!

          Show
          Mark Struberg added a comment - Rohit, is this fixed now? - txs!
          Hide
          Rohit Dilip Kelapure added a comment -

          Attaching a patch for this issue to explain my approach for fixing this issue and to elicit feedback.

          Show
          Rohit Dilip Kelapure added a comment - Attaching a patch for this issue to explain my approach for fixing this issue and to elicit feedback.

            People

            • Assignee:
              Mark Struberg
              Reporter:
              Rohit Dilip Kelapure
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development