Uploaded image for project: 'OpenWebBeans'
  1. OpenWebBeans
  2. OWB-468

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • M1, 1.0.0-alpha-2, 1.0.0, 1.1.0
    • 1.2.0
    • None
    • 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)

      Attachments

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

        Issue Links

          Activity

            People

              struberg Mark Struberg
              kelapure Rohit Dilip Kelapure
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: