1 Reply Latest reply on Jan 16, 2013 8:27 AM by Keith Babo

    JAXB Transformation not working with CDI Bean

    Viral Gohel Newbie

      Hi All,

       

      I have been developing a simple Bean Component Service and trying to invoke the same with SOAP using the SOAP Binding.

      I configure the JAXB Trannsformations for the same.

       

      While i try to invoke the service with a SOAP message generated via soap-ui, i get the below exception,

       

       

      Caused by: org.switchyard.exception.SwitchYardException: Failed to unmarshall for 'java:com.example.switchyard.switchyard_example.Invoice'.
                at org.switchyard.transform.jaxb.internal.JAXBUnmarshalTransformer.transform(JAXBUnmarshalTransformer.java:87) [switchyard-transform-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.transform.jaxb.internal.JAXBUnmarshalTransformer.transform(JAXBUnmarshalTransformer.java:43) [switchyard-transform-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.transform.TransformSequence.apply(TransformSequence.java:119) [switchyard-api-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.transform.TransformSequence.applySequence(TransformSequence.java:211) [switchyard-api-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.handlers.TransformHandler.handleMessage(TransformHandler.java:83) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.internal.DefaultHandlerChain.handleMessage(DefaultHandlerChain.java:148) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.internal.DefaultHandlerChain.handle(DefaultHandlerChain.java:121) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.internal.LocalDispatcher.dispatch(LocalExchangeBus.java:72) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.internal.ExchangeImpl.sendInternal(ExchangeImpl.java:267) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.internal.ExchangeImpl.send(ExchangeImpl.java:184) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.component.soap.InboundHandler.invoke(InboundHandler.java:213) [switchyard-component-soap-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:113) [switchyard-component-soap-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:43) [switchyard-component-soap-0.5.0.Final.jar:0.5.0.Final]
                ... 20 more
      Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"invoice"). Expected elements are (none)
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:662) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:258) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:253) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:120) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1063) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:498) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:480) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:75) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:150) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:244) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:127) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:323) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:306) [jaxb-impl-2.2.4.jar:2.2.4]
                at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:106) [jboss-jaxb-api_2.2_spec-1.0.3.Final.jar:1.0.3.Final]
                at org.switchyard.transform.jaxb.internal.JAXBUnmarshalTransformer.transform(JAXBUnmarshalTransformer.java:79) [switchyard-transform-0.5.0.Final.jar:0.5.0.Final]
                ... 32 more
      
      
      13:52:52,801 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default-workqueue-1) Application {urn:com.example.switchyard:switchyard-example:0.0.1-SNAPSHOT}Payments#{urn:com.example.switchyard:switchyard-example:0.0.1-SNAPSHOT}submit has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: Failed to unmarshall for 'java:com.example.switchyard.switchyard_example.Invoice'.
                at org.jboss.wsf.stack.cxf.JBossWSInvoker.createFault(JBossWSInvoker.java:246)
                at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:201)
                at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:127)
                at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.6.0_24]
                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.6.0_24]
                at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.6.0_24]
                at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
                at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
                at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
                at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:232)
                at org.apache.cxf.interceptor.OneWayProcessorInterceptor$1.run(OneWayProcessorInterceptor.java:130)
                at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$2.run(AutomaticWorkQueueImpl.java:353)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_24]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_24]
                at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]
      Caused by: org.switchyard.exception.SwitchYardException: Failed to unmarshall for 'java:com.example.switchyard.switchyard_example.Invoice'.
                at org.switchyard.transform.jaxb.internal.JAXBUnmarshalTransformer.transform(JAXBUnmarshalTransformer.java:87) [switchyard-transform-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.transform.jaxb.internal.JAXBUnmarshalTransformer.transform(JAXBUnmarshalTransformer.java:43) [switchyard-transform-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.transform.TransformSequence.apply(TransformSequence.java:119) [switchyard-api-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.transform.TransformSequence.applySequence(TransformSequence.java:211) [switchyard-api-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.handlers.TransformHandler.handleMessage(TransformHandler.java:83) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.internal.DefaultHandlerChain.handleMessage(DefaultHandlerChain.java:148) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.internal.DefaultHandlerChain.handle(DefaultHandlerChain.java:121) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.internal.LocalDispatcher.dispatch(LocalExchangeBus.java:72) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.internal.ExchangeImpl.sendInternal(ExchangeImpl.java:267) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.internal.ExchangeImpl.send(ExchangeImpl.java:184) [switchyard-runtime-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.component.soap.InboundHandler.invoke(InboundHandler.java:213) [switchyard-component-soap-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:113) [switchyard-component-soap-0.5.0.Final.jar:0.5.0.Final]
                at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:43) [switchyard-component-soap-0.5.0.Final.jar:0.5.0.Final]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_24]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.6.0_24]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.6.0_24]
                at java.lang.reflect.Method.invoke(Method.java:616) [rt.jar:1.6.0_24]
                at org.jboss.ws.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:111)
                at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:181)
                ... 14 more
      Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"invoice"). Expected elements are (none)
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:662) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:258) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:253) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:120) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:1063) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:498) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:480) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:75) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:150) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:244) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:127) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:323) [jaxb-impl-2.2.4.jar:2.2.4]
                at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:306) [jaxb-impl-2.2.4.jar:2.2.4]
                at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:106) [jboss-jaxb-api_2.2_spec-1.0.3.Final.jar:1.0.3.Final]
                at org.switchyard.transform.jaxb.internal.JAXBUnmarshalTransformer.transform(JAXBUnmarshalTransformer.java:79) [switchyard-transform-0.5.0.Final.jar:0.5.0.Final]
                ... 32 more
      
      
      

       

       

      My source for switchyard.xml has the following,

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      <switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-bean: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="switchyard-example" targetNamespace="urn:com.example.switchyard:switchyard-example:0.0.1-SNAPSHOT">
        <sca:composite name="switchyard-example" targetNamespace="urn:com.example.switchyard:switchyard-example:0.0.1-SNAPSHOT">
          <sca:component name="PaymentsBean">
            <bean:implementation.bean class="com.example.switchyard.switchyard_example.PaymentsBean"/>
            <sca:service name="Payments">
              <sca:interface.java interface="com.example.switchyard.switchyard_example.Payments"/>
            </sca:service>
          </sca:component>
          <sca:service name="PaymentsPortType" promote="PaymentsBean/Payments">
            <sca:interface.wsdl interface="Payments.wsdl#wsdl.porttype(PaymentsPortType)"/>
            <soap:binding.soap>
              <soap:contextMapper/>
              <soap:messageComposer unwrapped="true"/>
              <soap:wsdl>Payments.wsdl</soap:wsdl>
              <soap:wsdlPort>PaymentsPort</soap:wsdlPort>
              <soap:socketAddr>:18001</soap:socketAddr>
              <soap:contextPath>switchyard-example</soap:contextPath>
            </soap:binding.soap>
          </sca:service>
        </sca:composite>
        <transforms>
          <transform:transform.jaxb from="{urn:com.example.switchyard:switchyard-example:0.0.1-SNAPSHOT}submit" to="java:com.example.switchyard.switchyard_example.Invoice"/>
        </transforms>
      </switchyard>
      
      

       

      Can anyone please let me know what causes this or how do i apply the JAXB Transformations properly ?

       

      Attached is the application/project for reference.