7 Replies Latest reply on Sep 18, 2012 5:25 PM by Bryn Cooke

    Should Weld deployment fail if a superclass is not present?

    Bryn Cooke Newbie

      Hi, I have an issue with a deployment where a library contains code that is uses resteasy, but I don't need resteasy, so it is not on the classpath.

       

      Here is an example class which triggers the problem:

       

      class Foo implements MessageBodyReaderInterceptor {
      ...
      }
      

       

      Even though the class Foo is not used, weld is trying to process it and can't because the class MessageBodyReaderInterceptor cannot be loaded.

       

      Caused by: java.lang.NoClassDefFoundError: org/jboss/resteasy/spi/interception/MessageBodyReaderInterceptor
                at java.lang.ClassLoader.defineClass1(Native Method)
                at java.lang.ClassLoader.defineClass(ClassLoader.java:787)
                at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
                at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2904)
                at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
                at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
                at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
                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.environment.servlet.Listener.contextInitialized(Listener.java:182)
                at uk.co.novaware.core.ContextInitializer.onStartup(ContextInitializer.java:114)
                at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5274)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
                ... 7 more
      Caused by: java.lang.ClassNotFoundException: org.jboss.resteasy.spi.interception.MessageBodyReaderInterceptor
                at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
                at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
                ... 27 more
      
      

       

      Can anyone advise me is this is a bug or expected behaviour?


      Weld-1.1.8, Tomcat7

        • 1. Re: Should Weld deployment fail if a superclass is not present?
          Ales Justin Master

          Is this log under Error or Warn, as I would expect it under Warn, hence (semi)harmless.

          • 2. Re: Should Weld deployment fail if a superclass is not present?
            Bryn Cooke Newbie

            It's an uncaught exception, so weld stops processing classes at that point and the exception makes it's way all the way back to tomcat.

            • 3. Re: Should Weld deployment fail if a superclass is not present?
              Ales Justin Master

              Can you post stack-trace -- with full logs?

               

              Message was edited by: Ales Justin

              • 4. Re: Should Weld deployment fail if a superclass is not present?
                Ales Justin Master

                Or what about if you use latest 1.1.9. Weld?

                • 5. Re: Should Weld deployment fail if a superclass is not present?
                  Bryn Cooke Newbie

                  Hi, I gave 1.1.9-SNAPSHOT and 1.2.0-SNAPSHOT a go and got the same results.

                   

                  Here are some more of my logs, minus some stuff that doesn't provide any extra information/reveals more about my machine than I would like.

                  In case you are wondering why weld is being called from a context initializer, it is because the project that I am working on has special requirements regarding configuration that are not well suited to web.xml. In any case, the weld listener is called as it normally would be and I have narrowed down the issue to the inclusion of this one class.

                   

                  --SNIP--

                  21:02:54.580 [localhost-startStop-1] INFO  org.jboss.weld.Version - WELD-000900 1.1.8 (Final)

                  --SNIP--

                  21:02:55.471 [localhost-startStop-1] INFO  org.jboss.solder.core.CoreExtension - Preventing interface org.jboss.seam.mail.templating.velocity.package-info from being installed as required class org.apache.velocity.app.VelocityEngine could not be found

                  21:02:56.122 [localhost-startStop-1] INFO  org.jboss.solder.core.CoreExtension - Preventing class org.jboss.seam.international.locale.LocaleConfiguration from being installed as bean due to @Veto annotation

                  21:02:56.350 [localhost-startStop-1] INFO  org.jboss.solder.core.CoreExtension - Preventing interface org.jboss.seam.mail.templating.freemarker.package-info from being installed as required class freemarker.template.Template could not be found

                  Sep 15, 2012 9:02:56 PM org.apache.catalina.core.ContainerBase startInternal

                  SEVERE: A child container failed during start

                  java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/scheduler-webapp]]

                            at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)

                            at java.util.concurrent.FutureTask.get(FutureTask.java:111)

                            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)

                            at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:785)

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)

                            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)

                            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

                            at java.util.concurrent.FutureTask.run(FutureTask.java:166)

                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

                            at java.lang.Thread.run(Thread.java:722)

                  Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/scheduler-webapp]]

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

                            ... 7 more

                  Caused by: java.lang.NoClassDefFoundError: org/jboss/resteasy/spi/interception/MessageBodyReaderInterceptor

                            at java.lang.ClassLoader.defineClass1(Native Method)

                            at java.lang.ClassLoader.defineClass(ClassLoader.java:787)

                            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

                            at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2904)

                            at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)

                            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)

                            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)

                            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.environment.servlet.Listener.contextInitialized(Listener.java:182)

                            at uk.co.novaware.core.ContextInitializer.onStartup(ContextInitializer.java:112)

                            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5274)

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                            ... 7 more

                  Caused by: java.lang.ClassNotFoundException: org.jboss.resteasy.spi.interception.MessageBodyReaderInterceptor

                            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)

                            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)

                            ... 27 more

                   

                   

                  Sep 15, 2012 9:02:56 PM org.apache.catalina.core.ContainerBase startInternal

                  SEVERE: A child container failed during start

                  java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]

                            at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)

                            at java.util.concurrent.FutureTask.get(FutureTask.java:111)

                            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)

                            at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                            at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                            at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                            at org.apache.catalina.startup.Catalina.start(Catalina.java:684)

                            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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)

                            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:451)

                  Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

                            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)

                            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)

                            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)

                            at java.util.concurrent.FutureTask.run(FutureTask.java:166)

                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

                            at java.lang.Thread.run(Thread.java:722)

                  Caused by: org.apache.catalina.LifecycleException: A child container failed during start

                            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)

                            at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:785)

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                            ... 7 more

                   

                   

                  Sep 15, 2012 9:02:56 PM org.apache.catalina.startup.Catalina start

                  SEVERE: Catalina.start:

                  org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

                            at org.apache.catalina.startup.Catalina.start(Catalina.java:684)

                            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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)

                            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:451)

                  Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

                            at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                            ... 7 more

                  Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)

                            at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                            ... 9 more

                  Caused by: org.apache.catalina.LifecycleException: A child container failed during start

                            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)

                            at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)

                            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                            ... 11 more

                   

                   

                  Sep 15, 2012 9:02:56 PM org.apache.catalina.startup.Catalina start

                  INFO: Server startup in 4780 ms

                   

                   

                  I can sort of see what is happening:

                   

                  org.jboss.weld.bootstrap.BeanDeployer.addClass

                   

                  calls

                      private Class<?> loadClass(String className) {

                          try {

                              return resourceLoader.classForName(className);

                          } catch (ResourceLoadingException e) {

                              log.info(IGNORING_CLASS_DUE_TO_LOADING_ERROR, className);

                              xlog.catching(INFO, e);

                              return null;

                          }

                      }

                  But in my case it seems that a class with a missing super class will not cause an exception to be thrown. (Java7)

                   

                  So later org.jboss.weld.bootstrap.BeanDeployer.addClass calls:

                  org.jboss.weld.util.reflection.Reflections.isNonStaticInnerClass(Reflections.java:139)

                   

                  Which does throw an exception - which is not caught. However, it is not clear to me if this is a bug or a feature or even if it is covered in the CDI spec at all?

                  • 6. Re: Should Weld deployment fail if a superclass is not present?
                    Bryn Cooke Newbie

                    Actually rereading your first post, I guess you are saying that it shouldn't fail (and you would know more than anyone else).

                     

                    I'll create something minimal in weld SE that demonstrates the issue and if it behaves in the same way I'll submit a bug.

                    • 7. Re: Should Weld deployment fail if a superclass is not present?
                      Bryn Cooke Newbie

                      In case anyone wonders what this was, it only occures when the class being loaded has a nested class in it:

                       

                       

                      public class ErrorClass implements DoesntExist {

                       

                        public static class ThisWillCauseAnError {

                        }

                       

                        public void execute(Object input) {

                       

                        }

                      }

                       

                       

                       

                      https://issues.jboss.org/browse/WELD-1215