3 Replies Latest reply on Sep 18, 2013 5:34 AM by lostvicking

    Bean Component invocation failure

    lostvicking

      Hi all,

       

      Working with Switchyard 1.0 in Eclipse Juno and using the tooling provided. I'm getting an org.switchyard.component.bean.BeanComponentException when calling a web service method from my Switchyard project. Not too sure what to make of it since I have defined the service reference in the switchyard.xml. What I have currently is this:


      This is the bean that is injected with the web service and makes calls to it:


      @Service(Sale.class)

      public class SaleBean implements Sale, Base24 {

        @Inject @Reference

        za.co.fnb.base24.WsBICISOPortType WsBICISOPortType;

       

           @Override

             public AuthResponse doAuthRequest(AuthRequest autRequest) {

                     // ... this is the web service method I am calling:

                     POS210Type POS210 = WsBICISOPortType.op0200(POS200);

             }

      }

      ===========================================================================================================

      switchyard.xml:


      <?xml version="1.0" encoding="UTF-8"?>

      <switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:sy="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-bean:config:1.0" xmlns:resteasy="urn:switchyard-component-resteasy:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:soap="urn:switchyard-component-soap:config:1.0" xmlns:transform="urn:switchyard-config:transform:1.0" name="MPowaPOSToGateway" targetNamespace="urn:com.example.switchyard:MPowaPOSToGateway:1.0">

        <sca:composite name="MPowaPOSToGateway" targetNamespace="urn:com.example.switchyard:MPowaPOSToGateway:1.0">

          <sca:service name="PairingAndAuth" promote="PairingAndAuthBean/PairingAndAuth">

            <sca:interface.java interface="za.co.fnb.ms.interfaces.PairingAndAuth"/>

            <resteasy:binding.rest>

              <resteasy:contextMapper/>

              <resteasy:interfaces>za.co.fnb.ms.rest.resources.PairingAndAuthResource</resteasy:interfaces>

              <resteasy:contextPath>pairingAndAuth</resteasy:contextPath>

            </resteasy:binding.rest>

          </sca:service>

          <sca:component name="PairingAndAuthBean">

            <bean:implementation.bean class="za.co.fnb.ms.bean.PairingAndAuthBean"/>

            <sca:service name="PairingAndAuth">

              <sca:interface.java interface="za.co.fnb.ms.interfaces.PairingAndAuth"/>

            </sca:service>

          </sca:component>

          <sca:service name="Other" promote="OtherBean/Other">

            <sca:interface.java interface="za.co.fnb.ms.interfaces.Other"/>

            <resteasy:binding.rest>

              <resteasy:contextMapper/>

              <resteasy:interfaces>za.co.fnb.ms.rest.resources.OtherResource</resteasy:interfaces>

              <resteasy:contextPath>other</resteasy:contextPath>

            </resteasy:binding.rest>

          </sca:service>

          <sca:component name="OtherBean">

            <bean:implementation.bean class="za.co.fnb.ms.bean.OtherBean"/>

            <sca:service name="Other">

              <sca:interface.java interface="za.co.fnb.ms.interfaces.Other"/>

            </sca:service>

            <sca:reference name="TransactionDBService">

              <sca:interface.java interface="za.co.fnb.ms.ims.interfaces.TransactionDBService"/>

            </sca:reference>

          </sca:component>

          <sca:service name="Sale" promote="SaleBean/Sale">

            <sca:interface.java interface="za.co.fnb.ms.interfaces.Sale"/>

            <resteasy:binding.rest>

              <resteasy:contextMapper/>

              <resteasy:interfaces>za.co.fnb.ms.rest.resources.SaleResource</resteasy:interfaces>

              <resteasy:contextPath>sales</resteasy:contextPath>

            </resteasy:binding.rest>

          </sca:service>

          <sca:component name="SaleBean">

            <bean:implementation.bean class="za.co.fnb.ms.bean.SaleBean"/>

            <sca:service name="Sale">

              <sca:interface.java interface="za.co.fnb.ms.interfaces.Sale"/>

            </sca:service>

            <sca:reference name="Base24">

              <sca:interface.java interface="za.co.fnb.ms.b24.interfaces.Base24"/>

            </sca:reference>

            <sca:reference name="WsBICISOPortType">

              <sca:interface.java interface="za.co.fnb.base24.WsBICISOPortType"/>

            </sca:reference>

          </sca:component>

          <sca:component name="TransactionDBServiceBean">

            <bean:implementation.bean class="za.co.fnb.ms.bean.TransactionDBServiceBean"/>

            <sca:service name="TransactionDBService">

              <sca:interface.java interface="za.co.fnb.ms.ims.interfaces.TransactionDBService"/>

            </sca:service>

          </sca:component>

          <sca:reference name="WsBICISOPortType" multiplicity="0..1" promote="SaleBean/WsBICISOPortType">

            <sca:interface.wsdl interface="wsdl/BICISOWSDL.wsdl#wsdl.porttype(wsBICISOPortType)"/>

            <soap:binding.soap>

              <soap:contextMapper/>

              <soap:wsdl>wsdl/BICISOWSDL.wsdl</soap:wsdl>

              <soap:wsdlPort>wsBICISOPort</soap:wsdlPort>

              <soap:endpointAddress>http://172.18.191.200:31340/soap</soap:endpointAddress>

            </soap:binding.soap>

          </sca:reference>

        </sca:composite>

        <transforms>

          <transform:transform.jaxb from="java:za.co.fnb.base24.POS200Type" to="{http://tempuri.org/wsBICISO/schemas}POS_200"/>

          <transform:transform.jaxb from="{http://tempuri.org/wsBICISO/schemas}POS_210" to="java:za.co.fnb.base24.POS210Type"/>

        </transforms>

      </switchyard>

       

      ===========================================================================================================

       

      Exception getting thrown:

      17 Sep 2013 10:54:14,238 ERROR [za.co.fnb.ms.bean.SaleBean] (http-jboss_host/127.0.0.1:8080-1) za.co.fnb.ms.bean.SaleBean.doAuthRequest:716 - Event end for event: Event type: Method call, event name: op0200, exception thrown: null, UniqueID MSLoggerID5247378810028484669-1379408054049: java.lang.reflect.UndeclaredThrowableException

        at com.sun.proxy.$Proxy45.op0200(Unknown Source)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_25]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_25]

        at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_25]

        at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:45) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]

        at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105) [weld-core-1.1.13.Final-redhat-1.jar:1.1.13.Final-redhat-1]

        at org.jboss.weld.proxies.WsBICISOPortType$1366014918$Proxy$_$$_WeldClientProxy.op0200(WsBICISOPortType$1366014918$Proxy$_$$_WeldClientProxy.java)

        at za.co.fnb.ms.bean.SaleBean.doAuthRequest(SaleBean.java:711) [MPowaPOSToGateway-0.0.1-SNAPSHOT.jar:]

        at za.co.fnb.ms.bean.SaleBean.purchase(SaleBean.java:94) [MPowaPOSToGateway-0.0.1-SNAPSHOT.jar:]

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_25]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_25]

        at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_25]

        at org.switchyard.component.bean.ServiceProxyHandler.handle(ServiceProxyHandler.java:161)

        at org.switchyard.component.bean.ServiceProxyHandler.handleMessage(ServiceProxyHandler.java:92)

        at org.switchyard.bus.camel.processors.ProviderProcessor.process(ProviderProcessor.java:28)

        at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.switchyard.bus.camel.audit.FaultProcessor.process(FaultProcessor.java:44)

        at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

        at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)

        at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

        at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:104)

        at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:78)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.switchyard.bus.camel.audit.FaultProcessor.process(FaultProcessor.java:44)

        at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)

        at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:122)

        at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

        at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)

        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

        at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61)

        at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)

        at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)

        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)

        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)

        at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)

        at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:360)

        at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:331)

        at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:227)

        at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:331)

        at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:153)

        at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:106)

        at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:92)

        at org.switchyard.bus.camel.ExchangeDispatcher.dispatch(ExchangeDispatcher.java:87)

        at org.switchyard.bus.camel.CamelExchange.sendInternal(CamelExchange.java:224)

        at org.switchyard.bus.camel.CamelExchange.send(CamelExchange.java:174)

        at org.switchyard.component.resteasy.InboundHandler.invoke(InboundHandler.java:116)

        at org.switchyard.component.resteasy.util.RESTEasyProxy.invoke(RESTEasyProxy.java:96)

        at com.sun.proxy.$Proxy82.purchase(Unknown Source)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_25]

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_25]

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_25]

        at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_25]

        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]

        at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]

        at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]

        at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]

        at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]

        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]

        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]

        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]

        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]

        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)

        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)

        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)

        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)

        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)

        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)

        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)

        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)

        at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]

      Caused by: org.switchyard.component.bean.BeanComponentException: Bean Component invocation failure.  Service 'WsBICISOPortType', operation 'op0200'.

        at org.switchyard.component.bean.ClientProxyBean$ClientProxyInvocationHandler.invoke(ClientProxyBean.java:302)

        ... 113 more

       

       

      Regards

      Vic

        • 1. Re: Bean Component invocation failure
          lostvicking

          Ok, I think I know what causes this. What happened was that the web service replied to the SOAP message I've sent it with a SOAP fault message, since the the WSDL specifies that the return type for the web service method I called is of type POS_210 it seems that this breaks the communication.

           

          So just to recap, the web service validation on the remote side sent a SOAP fault message in response to my message and this caused the above exception to be thrown, I've verified this using Wireshark. The SOAP fault message looks like this:

           

          <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

             <SOAP-ENV:Body>

                <SOAP-ENV:Fault>

                   <faultcode>SOAP-ENV:Client</faultcode>

                   <faultstring>Client Error</faultstring>

                   <detail xmlns:err="http://www.insession.com/soap/error/">

                      <err:code>20011</err:code>

                      <err:description>Non-numeric character in numeric data. DSR item is [TRAN_AMT].</err:description>

                   </detail>

                </SOAP-ENV:Fault>

             </SOAP-ENV:Body>

          </SOAP-ENV:Envelope>

           

          Now, I'm not sure how to proceed and get Switchyard to cater for the scenario when the remote web service validation returns an error instead of the object type specified in the WSDL? To conclude in this case there are two possible outcomes to every web service method call, one when everything is fine and message validation passes on the message and returns the correct object back to the caller and two when the validation returns the SOAP fault message.

           

          Regards

          Vic

          • 2. Re: Re: Bean Component invocation failure
            synclpz

            I don't know how the dev team proposes to cope with @Reference-thrown exceptions (they are not only SOAP-related), but we managed to catch BeanComponentException and handle it this way. This is the way for HTTP Binding example:

             

            try {
                 //invoke some @Reference method
            } catch (Throwable t) {
            if (t instanceof UndeclaredThrowableException) {
              logger.error("Cannot process request", t);
              Throwable tt = ((UndeclaredThrowableException) t)
              .getUndeclaredThrowable();
              if (tt instanceof BeanComponentException) {
              Message m = ((BeanComponentException) tt).getFaultExchange()
              .getMessage(); //Here you can get yor SOAP-fault I think! But we get HTTP-response
              Object content = m.getContent();
              if (content instanceof HttpResponseBindingData) {
              response.setErrorId(((HttpResponseBindingData) content)
              .getStatus());
              try {
              response.setErrorMessage(((HttpResponseBindingData) content)
              .getBodyAsString());
              } catch (UnsupportedEncodingException e) {
              logger.error(
              "Cannot read response body on bad response", e);
              }
              } else {
              response.setErrorId(ERROR_INTERNAL);
              response.setErrorMessage(tt.getMessage());
              }
              } else if (tt instanceof HandlerException) {
              Throwable ttt = ((HandlerException) tt).getCause();
              if (ttt != null) {
              if (ttt instanceof HttpHostConnectException) {
              response.setErrorId(ERROR_CONNECT);
              response.setErrorMessage(ttt.getMessage());
              } else if (ttt instanceof UnknownHostException) {
              response.setErrorId(ERROR_CONNECT);
              response.setErrorMessage(ttt.toString());
              } else if (ttt instanceof SocketException) {
              response.setErrorId(ERROR_CONNECT);
              response.setErrorMessage(ttt.toString());
              } else if (ttt instanceof NoRouteToHostException) {
              response.setErrorId(ERROR_CONNECT);
              response.setErrorMessage(ttt.toString());
              } else {
              response.setErrorId(ERROR_INTERNAL);
              response.setErrorMessage(ttt.getMessage());
              }
              } else {
              response.setErrorId(ERROR_INTERNAL);
              response.setErrorMessage(tt.getMessage());
              }
              } else {
              response.setErrorId(ERROR_INTERNAL);
              response.setErrorMessage(tt.getMessage());
              }
            }
            
            
            • 3. Re: Bean Component invocation failure
              lostvicking

              Thanks Viktor, that works for me.