Make BeansDeployer.deployFromClassPath(ScannerService) resilient to ClassNotFoundException and NoClassDefFoundError's ---------------------------------------------------------------------------------------------------------------------
Key: OWB-468 URL: https://issues.apache.org/jira/browse/OWB-468 Project: OpenWebBeans Issue Type: Bug Components: Core, Java EE Integration, Lifecycle Affects Versions: 1.0.0-alpha-2, 1.1.0, 1.0.1, 1.0.0 Environment: Windows Server 2003 Reporter: Rohit Dilip Kelapure Assignee: Gurkan Erdogdu Sometimes in tiered classloading environments during lifecycle start --> BeansDeployer deploy --> AnnotatedElementFactory.newAnnotatedType(Class<X>) 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) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.