3 Replies Latest reply on May 25, 2011 3:50 PM by Frank Upgang

    Weld 1.1.1 and Tomcat7 problems

    Ulf Almehed Newbie

      When upgrading from Weld 1.1.0.Beta2 to 1.1.1.Final and Tomcat server from 7.0.6 to 7.0.14, my application stopped working. I get the following exception:


      ALLVARLIG: Exception sending context initialized event to listener instance of class org.jboss.weld.environment.servlet.Listener
      java.lang.NoClassDefFoundError: org/apache/AnnotationProcessor
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
        at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)
        at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
        at org.jboss.weld.environment.tomcat.Tomcat6Container.initialize(Tomcat6Container.java:47)
        at org.jboss.weld.environment.servlet.Listener.contextInitialized(Listener.java:184)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
        at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
        at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.ClassNotFoundException: org.apache.AnnotationProcessor
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
        ... 26 more



           
      Any ideas? Workarounds?


      Kind Regards,
      /Ulf

        • 1. Re: Weld 1.1.1 and Tomcat7 problems
          Frank Upgang Newbie

          This might be caused by the following bug:
          https://issues.jboss.org/browse/WELD-879


          The workaround mentioned in the comment section worked for me:



          You can workaround the problem by placing proper org.jboss.weld.environment.Container file into your app's META-INF/services.

          The file contains the text:



          org.jboss.weld.environment.tomcat7.Tomcat7Container

          In my setting the file is placed in:
          WEB-INF\classes\META-INF\services\

          • 2. Re: Weld 1.1.1 and Tomcat7 problems
            Ulf Almehed Newbie

            Thanks for your reply. Unfortunately it doesn't seem to help in my case. I've tried every position of the file I can think of, but I still get the same exception when the application starts.


            After changing to version 1.1.0.Final of Weld it works though, so it looks like this problem has been introduced in the latest release.


            Kind Regards /Ulf

            • 3. Re: Weld 1.1.1 and Tomcat7 problems
              Frank Upgang Newbie

              Did you notice the following line of the stacktrace:



              at org.jboss.weld.environment.tomcat.Tomcat6Container.initialize(Tomcat6Container.java:47)

              This fits well to the above mentioned bug (Tomcat 7 container is identified as Tomcat 6), that is reported for version 1.1.1 Final.


              The class AnnotationProcessor seems no longer be part of Tomcat 7, as the changelog says:



              Switch from AnnotationProcessor to InstanceManager.

              In my project I can reproduce exactly the same exception, if i remove the file services\org.jboss.weld.environment.Container. Just like in your case, I ran into trouble after switching to version 1.1.1.


              I wonder what is different in your setup...
              Greetings