Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1215

Nested class within an invalid class causes deployment failure

    Details

    • Steps to Reproduce:
      Hide

      Create a class like this:

      public class ErrorClass implements DoesntExist {
      
      	public static class ThisWillCauseAnError {
      	}
      
      	public void execute(Object input) {
      
      	}
      }
      
      Show
      Create a class like this: public class ErrorClass implements DoesntExist { public static class ThisWillCauseAnError { } public void execute( Object input) { } }

      Description

      If there is a library that contains a class that is invalid because it implements something that is not on the classpath then if it also contains a nested class then deployment will fail.

      Here is example output from weld SE in a junit test demonstrating this behaviour:

      java.lang.NoClassDefFoundError: org/apache/commons/collections/Closure
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:787)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:447)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      at java.lang.Class.getDeclaringClass(Native Method)
      at java.lang.Class.getEnclosingClass(Class.java:1105)
      at java.lang.Class.getSimpleBinaryName(Class.java:1240)
      at java.lang.Class.isMemberClass(Class.java:1230)
      at org.jboss.weld.util.reflection.Reflections.isNonStaticInnerClass(Reflections.java:139)
      at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:78)
      at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:123)
      at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:184)
      at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:350)
      at org.jboss.weld.bootstrap.api.helpers.ForwardingBootstrap.deployBeans(ForwardingBootstrap.java:70)
      at org.jboss.weld.environment.se.Weld.initialize(Weld.java:133)
      at org.test.AppTest.test(AppTest.java:16)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.Closure
      at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      ... 47 more

      Attached is a simple project that demonstrates the issue

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                luksa Marko Luksa
                Reporter:
                bryncooke Bryn Cooke
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: