7 Replies Latest reply on Jan 9, 2012 9:29 AM by Fabricio Lemos

    Seam Rest: @Inject @RestClient fails

    Fabricio Lemos Newbie

      When I try to


      @Inject @RestClient



      the app fails with the error below. new ClientRequest(url) works ok. I´m using Seam Rest 3.1.0.RC1 and Jboss 7.1.0CR1




      15:18:27,139 GRAVE [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-2) Error Rendering View[/autenticacao.xhtml]: java.lang.RuntimeException: Exception invoking method [createExecutor] on object [org.jboss.seam.rest.client.DefaultClientExecutorProducer@1072375], using arguments []
              at org.jboss.solder.reflection.Reflections.invokeMethod(Reflections.java:480) [solder-api-3.1.0.Beta5.jar:]
              at org.jboss.solder.reflection.Reflections.invokeMethod(Reflections.java:403) [solder-api-3.1.0.Beta5.jar:]
              at org.jboss.solder.reflection.annotated.InjectableMethod.invoke(InjectableMethod.java:175) [solder-impl-3.1.0.Beta5.jar:]
              at org.jboss.solder.reflection.annotated.InjectableMethod.invoke(InjectableMethod.java:132) [solder-impl-3.1.0.Beta5.jar:]
              at org.jboss.solder.bean.defaultbean.DefaultProducerMethod.getValue(DefaultProducerMethod.java:52) [solder-impl-3.1.0.Beta5.jar:]
              at org.jboss.solder.bean.defaultbean.AbstractDefaultProducerBean.create(AbstractDefaultProducerBean.java:60) [solder-impl-3.1.0.Beta5.jar:]
              at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:61) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:616) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:681) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.injection.ParameterInjectionPoint.getValueToInject(ParameterInjectionPoint.java:120) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.injection.MethodInjectionPoint.getParameterValues(MethodInjectionPoint.java:217) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:137) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:133) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:299) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:61) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:616) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:681) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:118) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:703) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:712) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:161) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:157) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:131) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:153) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:290) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:61) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:616) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:681) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:118) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:703) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:712) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:161) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:157) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:131) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:153) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:290) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:107) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:616) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.AbstractReceiverBean.getReceiver(AbstractReceiverBean.java:73) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.ProducerField$1.produce(ProducerField.java:119) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:299) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:61) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:616) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.el.AbstractWeldELResolver.lookup(AbstractWeldELResolver.java:127) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.weld.el.AbstractWeldELResolver.getValue(AbstractWeldELResolver.java:96) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.jboss.as.weld.webtier.jsf.ForwardingELResolver.getValue(ForwardingELResolver.java:46) [jboss-as-weld-7.1.0.CR1b.jar:7.1.0.CR1b]
              at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175) [jboss-el-api_2.2_spec-1.0.0.Final.jar:1.0.0.Final]
              at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
              at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
              at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:71) [jbossweb-7.0.7.Final.jar:]
              at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189) [jbossweb-7.0.7.Final.jar:]
              at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
              at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
              at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
              at javax.faces.component.UIOutput.getValue(UIOutput.java:169) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
              at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
              at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
              at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
              at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
              at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
              at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
              at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.7.Final.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.7.Final.jar:]
              at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.4.Final.jar:2011-11-22 20:01]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.7.Final.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.7.Final.jar:]
              at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65) [solder-impl-3.1.0.Beta5.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.7.Final.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.7.Final.jar:]
              at org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74) [solder-impl-3.1.0.Beta5.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.7.Final.jar:]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.7.Final.jar:]
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.7.Final.jar:]
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.7.Final.jar:]
              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:151) [jboss-as-web-7.1.0.CR1b.jar:7.1.0.CR1b]
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.7.Final.jar:]
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.7.Final.jar:]
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.7.Final.jar:]
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.7.Final.jar:]
              at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.7.Final.jar:]
              at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.7.Final.jar:]
              at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033) [jbossweb-7.0.7.Final.jar:]
              at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]
      Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.<init>(Lorg/apache/http/client/HttpClient;)V" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/jboss/seam/rest/client/DefaultClientExecutorProducer, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, org/jboss/resteasy/client/core/executors/ApacheHttpClient4Executor, have different Class objects for the type org/apache/http/client/HttpClient used in the signature
              at org.jboss.seam.rest.client.DefaultClientExecutorProducer.createExecutor(DefaultClientExecutorProducer.java:42) [seam-rest-3.1.0.CR1.jar:]
              at org.jboss.seam.rest.client.DefaultClientExecutorProducer$Proxy$_$$_WeldClientProxy.createExecutor(DefaultClientExecutorProducer$Proxy$_$$_WeldClientProxy.java) [seam-rest-3.1.0.CR1.jar:]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_25]
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_25]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_25]
              at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_25]
              at org.jboss.solder.reflection.Reflections.invokeMethod(Reflections.java:474) [solder-api-3.1.0.Beta5.jar:]
              ... 94 more



        • 1. Re: Seam Rest: @Inject @RestClient fails
          Jason Porter Master

          That root cause (the linkageError) sounds like you multiple rest client instances on the classpath.

          • 2. Re: Seam Rest: @Inject @RestClient fails
            Fabricio Lemos Newbie

            The only instance that I have is resteasy-jaxrs-2.1.0.GA.jar

            • 3. Re: Seam Rest: @Inject @RestClient fails
              Jason Porter Master

              Wait, having re-read the exception it almost seems like Seam Rest was using a different version of Apache HttpClient than what you have, or you have two instances of the class somewhere.

              • 4. Re: Seam Rest: @Inject @RestClient fails
                Fabricio Lemos Newbie

                I tried to isolate the problem in a minimum project. This is my pom:




                <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
                     <modelVersion>4.0.0</modelVersion>
                     <groupId>teste</groupId>
                     <artifactId>projeto-teste</artifactId>
                     <version>0.0.1-SNAPSHOT</version>
                     <packaging>war</packaging>
                
                     <dependencyManagement>
                          <dependencies>
                               <dependency>
                                    <groupId>org.jboss.seam</groupId>
                                    <artifactId>seam-bom</artifactId>
                                    <version>3.1.0.CR1</version>
                                    <type>pom</type>
                                    <scope>import</scope>
                               </dependency>
                          </dependencies>
                     </dependencyManagement>
                
                     <dependencies>
                          <dependency>
                               <groupId>org.jboss.resteasy</groupId>
                               <artifactId>resteasy-jaxrs</artifactId>
                          </dependency>
                          <dependency>
                               <groupId>org.jboss.seam.rest</groupId>
                               <artifactId>seam-rest</artifactId>
                          </dependency>
                          <dependency>
                               <groupId>javax.enterprise</groupId>
                               <artifactId>cdi-api</artifactId>
                               <scope>provided</scope>
                          </dependency>
                     </dependencies>
                
                </project>



                • 6. Re: Seam Rest: @Inject @RestClient fails
                  Jozef Hartinger Master

                  Fabricio,


                  RESTEasy is part of JBoss AS 7 and thus you should not bundle it with your application. Note that for using the rest client you also need the http components library, which is also available within JBoss AS 7 but is not automatically added to the classpath. Therefore, you should add the following line to the manifest file: Dependencies: org.apache.httpcomponents as described in the docs. This step can be automated using the maven war plugin.

                  • 7. Re: Seam Rest: @Inject @RestClient fails
                    Fabricio Lemos Newbie

                    It´s working now, thank you Jozef and Jason. I configured the war plugin using:




                    <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
                         <artifactId>maven-war-plugin</artifactId>
                         <configuration>
                              <archive>
                                   <manifestEntries>
                                        <Dependencies>org.apache.httpcomponents</Dependencies>
                                   </manifestEntries>
                              </archive>
                         </configuration>
                    </plugin>