7 Replies Latest reply on Jan 17, 2012 11:21 AM by lightguard

    seam rest class not found exception

    stenlylee

      I add seam rest dependency in my pom



      <dependency>
        <groupId>org.jboss.seam.rest</groupId>
        <artifactId>seam-rest</artifactId>
        <version>3.1.0.Final</version>
      </dependency>




      and I use FreeMarker, JBoss AS 7.1.0.Beta1b


      when jboss run, I got NoClassDefFoundError: apache velocity and apache HTTPClient


      I haven't found any config is needed by seam rest, so what's wrong?


      thx

        • 1. Re: seam rest class not found exception
          lightguard

          I believe you are experiencing a similar issue as http://seamframework.org/Community/SeamRestInjectRestClientFails please see that thread for more info.

          • 2. Re: seam rest class not found exception
            stenlylee

            thank for you reply first, Jason


            well, I haven't notice the tips about apache HTTPClient in document. when I add the dependency, the error has gone


            but what about apache velocity? I haven't and will not use the framework in my project


            why I need to add the dependency?


            thx again

            • 3. Re: seam rest class not found exception
              lightguard

              What's in your pom and what's the stack trace?

              • 4. Re: seam rest class not found exception
                stenlylee


                     <properties>
                          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                          <org.jboss.resteasy.version>2.3.0.GA</org.jboss.resteasy.version>
                          <org.jboss.as.version>7.1.0.Beta1b</org.jboss.as.version>
                     </properties>
                     <dependencyManagement>
                          <dependencies><dependency><groupId>org.jboss.spec</groupId><artifactId>jboss-javaee-web-6.0</artifactId><version>3.0.0.Beta1</version><type>pom</type><scope>import</scope></dependency></dependencies>
                     </dependencyManagement>
                     <dependencies>
                          <dependency><groupId>org.jboss.spec.javax.servlet</groupId>          <artifactId>jboss-servlet-api_3.0_spec</artifactId></dependency>
                          <dependency><groupId>javax.enterprise</groupId>                         <artifactId>cdi-api</artifactId>                                                                                                         <scope>provided</scope></dependency>
                          <dependency><groupId>org.jboss.spec.javax.annotation</groupId>     <artifactId>jboss-annotations-api_1.1_spec</artifactId>                                                                                <scope>provided</scope></dependency>
                          <dependency><groupId>org.jboss.resteasy</groupId>                    <artifactId>resteasy-jaxrs</artifactId>                         <version>${org.jboss.resteasy.version}</version>               <scope>provided</scope></dependency>
                          <dependency><groupId>org.jboss.resteasy</groupId>                    <artifactId>resteasy-jaxb-provider</artifactId>               <version>${org.jboss.resteasy.version}</version>               <scope>provided</scope></dependency>
                          <dependency><groupId>org.jboss.resteasy</groupId>                    <artifactId>resteasy-multipart-provider</artifactId>     <version>${org.jboss.resteasy.version}</version>               <scope>provided</scope></dependency>
                          <dependency><groupId>org.jboss.resteasy</groupId>                    <artifactId>resteasy-cache-core</artifactId>               <version>${org.jboss.resteasy.version}</version>               <scope>provided</scope></dependency>
                          <dependency><groupId>org.jboss.resteasy</groupId>                    <artifactId>resteasy-yaml-provider</artifactId>               <version>${org.jboss.resteasy.version}</version>               <scope>provided</scope></dependency>
                          <dependency><groupId>org.jboss.resteasy</groupId>                    <artifactId>resteasy-atom-provider</artifactId>               <version>${org.jboss.resteasy.version}</version>               <scope>provided</scope></dependency>
                          <dependency><groupId>org.jboss.resteasy</groupId>                    <artifactId>async-http-jbossweb</artifactId>               <version>${org.jboss.resteasy.version}</version>               <scope>provided</scope></dependency>
                           <dependency><groupId>org.jboss.seam.rest</groupId>                    <artifactId>seam-rest</artifactId>                              <version>3.1.0.Final</version></dependency>
                          <dependency><groupId>org.slf4j</groupId>                              <artifactId>slf4j-simple</artifactId>                         <version>1.6.4</version></dependency>
                          <dependency><groupId>mysql</groupId>                                   <artifactId>mysql-connector-java</artifactId>               <version>5.1.18</version></dependency>
                          <dependency><groupId>org.freemarker</groupId>                         <artifactId>freemarker</artifactId>                              <version>2.3.18</version></dependency>
                          <dependency><groupId>org.apache.httpcomponents</groupId>          <artifactId>httpclient</artifactId>                              <version>4.2-alpha1</version></dependency>
                     </dependencies>
                     <build>
                          <finalName>${project.artifactId}</finalName>
                          <plugins>
                               <plugin><artifactId>maven-compiler-plugin</artifactId><version>2.3.2</version><configuration><source>1.7</source><target>1.7</target><fork>true</fork><meminitial>128m</meminitial><maxmem>512m</maxmem></configuration></plugin>
                               <plugin><artifactId>maven-war-plugin</artifactId><version>2.1.1</version><configuration><failOnMissingWebXml>false</failOnMissingWebXml><archive><addMavenDescriptor>false</addMavenDescriptor></archive></configuration></plugin>
                               <plugin><groupId>org.jboss.as.plugins</groupId><artifactId>jboss-as-maven-plugin</artifactId><version>${org.jboss.as.version}</version></plugin>
                          </plugins>
                     </build>
                     <repositories>
                          <repository>
                               <id>sonatype-nexus-snapshots</id><name>Sonatype Nexus Plugin Snapshots</name><url>https://oss.sonatype.org/content/repositories/snapshots</url>
                               <releases><enabled>false</enabled></releases><snapshots><enabled>true</enabled></snapshots>
                          </repository>
                     </repositories>
                     <pluginRepositories>
                          <pluginRepository>
                               <id>sonatype-nexus-plugin-snapshots</id><name>Sonatype Nexus Plugin Snapshots</name><url>https://oss.sonatype.org/content/repositories/snapshots</url>
                               <releases><enabled>false</enabled></releases><snapshots><enabled>true</enabled></snapshots>
                          </pluginRepository>
                     </pluginRepositories>
                     <profiles>
                          <profile><id>default</id><activation><activeByDefault>true</activeByDefault></activation><build><plugins><plugin><artifactId>maven-surefire-plugin</artifactId><version>2.11</version><configuration><skip>true</skip></configuration></plugin></plugins></build></profile>
                     </profiles>
                



                • 5. Re: seam rest class not found exception
                  stenlylee


                  23:30:23,997 INFO  [org.jboss.weld.ClassLoading] (MSC service thread 1-2) WELD-000119 Not generating any bean definitions from org.jboss.seam.rest.templating.velocity.VelocityProvider because of underlying class loading error
                  23:30:23,998 INFO  [org.jboss.weld.ClassLoading] (MSC service thread 1-2) catching: org.jboss.weld.resources.spi.ResourceLoadingException: Error loading class org.jboss.seam.rest.templating.velocity.VelocityProvider
                       at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:152) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:86) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:115) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:171) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:336) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:81) [jboss-as-weld-7.1.0.CR1b.jar:7.1.0.CR1b]
                       at org.jboss.as.weld.services.WeldService.start(WeldService.java:89) [jboss-as-weld-7.1.0.CR1b.jar:7.1.0.CR1b]
                       at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)
                       at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)
                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0_01]
                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_01]
                       at java.lang.Thread.run(Thread.java:722) [:1.7.0_01]
                  Caused by: java.lang.NoClassDefFoundError: org/apache/velocity/context/Context
                       at java.lang.Class.getDeclaredFields0(Native Method) [:1.7.0_01]
                       at java.lang.Class.privateGetDeclaredFields(Class.java:2308) [:1.7.0_01]
                       at java.lang.Class.getDeclaredFields(Class.java:1760) [:1.7.0_01]
                       at org.jboss.weld.util.reflection.SecureReflections$4.work(SecureReflections.java:102) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.util.reflection.SecureReflections$4.work(SecureReflections.java:99) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.util.reflection.SecureReflectionAccess.runAndWrap(SecureReflectionAccess.java:63) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.util.reflection.SecureReflections.getDeclaredFields(SecureReflections.java:99) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:153) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:118) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:49) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:40) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       at com.google.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:355)
                       at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184)
                       at com.google.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153)
                       at com.google.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69)
                       at com.google.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:393)
                       at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:149) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
                       ... 11 more
                  Caused by: java.lang.ClassNotFoundException: org.apache.velocity.context.Context from [Module "deployment.makino.war:main" from Service Module Loader]
                       at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
                       at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
                       at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
                       at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
                       at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
                       ... 29 more
                  
                  23:30:24,017 INFO  [org.jboss.solder.core.CoreExtension] (MSC service thread 1-2) Preventing interface org.jboss.seam.rest.templating.velocity.package-info from being installed as required class org.apache.velocity.Template could not be found
                  23:30:25,158 INFO  [org.jboss.solder.exception.control.extension] (MSC service thread 1-2) Adding handler Qualifiers: [@org.jboss.seam.rest.exceptions.RestRequest()] TraversalMode: DEPTH_FIRST Handles Type: class java.lang.Throwable Precedence: -100 [method] public org.jboss.seam.rest.exceptions.integration.CatchExceptionMapper.handleException(CaughtException<Throwable>, ResponseBuilder) to known handlers
                  23:30:25,162 INFO  [org.jboss.solder.exception.control.extension] (MSC service thread 1-2) Adding handler Qualifiers: [@org.jboss.seam.rest.exceptions.RestRequest()] TraversalMode: DEPTH_FIRST Handles Type: class org.jboss.seam.rest.validation.ValidationException Precedence: -100 [method] public org.jboss.seam.rest.exceptions.integration.CatchValidationExceptionHandler.handleValidationException(CaughtException<ValidationException>, ResponseBuilder) to known handlers
                  23:30:26,076 INFO  [org.jboss.seam.rest.exceptions.SeamExceptionMapper] (MSC service thread 1-3) Processing exception mapping configuration.
                  23:30:26,077 INFO  [org.jboss.seam.rest.SeamRestStartup] (MSC service thread 1-3) Seam REST null (Client integration: enabled, Catch integration: disabled, 0 exception mapping rules, Templating provider: org.jboss.seam.rest.templating.freemarker.FreeMarkerProvider)
                  



                  • 6. Re: seam rest class not found exception
                    stenlylee

                    these stack trace shows on JBoss AS startup
                    when I comment seam rest dependency, no stack trace

                    • 7. Re: seam rest class not found exception
                      lightguard

                      Looks to me like they're just INFO. We have the same problem in a couple other modules, you can ignore them. In a nutshell what has happened is there's an integration point with Velocity which is purely optional, but Weld has to load the class because it's part of the bean archive, however, it cannot load the class because of the missing Velocity classes.


                      Short answer, not a bug, ignore them. We need to split out the classes into a different jar.