6 Replies Latest reply on Dec 16, 2014 4:02 PM by magick93

    Resteasy client problems

    magick93

      Hi guys

       

      Im trying to create a simple REST client in SY. Can anyone help identify what I am doing wrong?

       

      I am getting the following error:

      [ERROR] Failed to execute goal org.switchyard:switchyard-plugin:2.0.0.Alpha3:configure (default) on project svs.kreator: SWITCHYARD011602: Model [org.switchyard.config.model.switchyard.v1.V1SwitchYardModel] is invalid: cvc-complex-type.2.4.a: Invalid content was found starting with element 'trfm:transform.json'. One of '{"urn:switchyard-config:switchyard:2.0":transforms, "urn:switchyard-config:switchyard:2.0":validates, "urn:switchyard-config:switchyard:2.0":domain, "urn:switchyard-config:switchyard:2.0":artifacts}' is expected. -> [Help 1]

       

      And here is my switchyard.xml file:

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      <sy:switchyard 
      xmlns:bean="urn:switchyard-component-bean:config:2.0" 
      xmlns:trfm="urn:switchyard-config:transform:2.0" 
      xmlns:resteasy="urn:switchyard-component-resteasy:config:2.0" 
      xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" 
      xmlns:sy="urn:switchyard-config:switchyard:2.0" 
      name="svs.kreator" 
      targetNamespace="urn:com.domain:svs.kreator:1.0">
        <sca:composite name="svs.kreator" targetNamespace="urn:com.domain:svs.kreator:1.0">
          <sca:component name="MyAccountService">
            <bean:implementation.bean class="com.domain.svs.kreator.MyAccountServiceBean"/>
            <sca:service name="MyAccountService">
              <sca:interface.java interface="com.domain.svs.kreator.MyAccountService"/>
            </sca:service>
            <sca:reference name="SvsResource">
              <sca:interface.java interface="com.domain.svs.kreator.SvsResource"/>
            </sca:reference>
          </sca:component>
          <sca:reference name="SvsAccountReference" multiplicity="0..1" promote="MyAccountService/SvsResource">
            <sca:interface.java interface="com.domain.svs.kreator.SvsAccountClient"/>
            <resteasy:binding.rest name="rest1">
              <resteasy:interfaces>com.domain.svs.kreator.SvsResource</resteasy:interfaces>
              <resteasy:address>https://www.myserviceprovider.com/en/index.php</resteasy:address>
            </resteasy:binding.rest>
          </sca:reference>
        </sca:composite>
        <trfm:transform.json
                  from="java:com.domain.svs.kreator.SvsAccount"
                  to="{urn:com.domain:svs.kreator:1.0}svsAccount"/>
      </sy:switchyard>
      

       

      Note, if I do not include the transformation tags in the xml, then I get the following errors:

       

      Caused by: org.jboss.resteasy.client.exception.ResteasyClientException: Unexpected exception type

        at org.jboss.resteasy.client.exception.mapper.ApacheHttpClient4ExceptionMapper.toException(ApacheHttpClient4ExceptionMapper.java:73)

        at org.jboss.resteasy.client.exception.mapper.ApacheHttpClient4ExceptionMapper.toException(ApacheHttpClient4ExceptionMapper.java:59)

        at org.switchyard.component.resteasy.util.ClientInvoker.invoke(ClientInvoker.java:341)

        at org.switchyard.component.resteasy.OutboundHandler.handleMessage(OutboundHandler.java:144)

        ... 119 more

      Caused by: java.lang.RuntimeException: could not find writer for content-type application/json type: com.domain.svs.kreator.SvsAccount

        at org.jboss.resteasy.client.ClientRequest.writeRequestBody(ClientRequest.java:470)

        at org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.writeRequestBodyToOutputStream(ApacheHttpClient4Executor.java:393)

        at org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.buildEntity(ApacheHttpClient4Executor.java:360)

        at org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.loadHttpMethod(ApacheHttpClient4Executor.java:332)

        at org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.execute(ApacheHttpClient4Executor.java:180)

        at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:39)

        at org.jboss.resteasy.plugins.interceptors.encoding.AcceptEncodingGZIPInterceptor.execute(AcceptEncodingGZIPInterceptor.java:40)

        at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:45)

        at org.jboss.resteasy.client.ClientRequest.execute(ClientRequest.java:444)

        at org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:688)

        at org.switchyard.component.resteasy.util.ClientInvoker.invoke(ClientInvoker.java:335)

        ... 120 more

        • 1. Re: Resteasy client problems
          igarashitm

          Did you edit switchyard.xml manually? Your config is really missing <transforms> tag which is supposed to contain <transform> tag.

          • 2. Re: Resteasy client problems
            trohovsky

            Hi Anton,

             

            the transform.json elements should be encapsulated with the transforms element. Just type around <sy:transforms> ... </sy:transforms> and it should be fine. Did you created the switchyard.xml file by the SY editor or manually?

             

            Tomas

            • 3. Re: Resteasy client problems
              magick93

              Yes, I did manually edit the xml. I could not find any other way of adding them.

               

              However, for json, is it needed to have transformers?

              • 4. Re: Resteasy client problems
                magick93

                I have corrected the sy.xml, see below - but am still getting the same error:

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

                <sy:switchyard xmlns:bean="urn:switchyard-component-bean:config:2.0"

                xmlns:trfm="urn:switchyard-config:transform:2.0"

                xmlns:resteasy="urn:switchyard-component-resteasy:config:2.0"

                xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"

                xmlns:sy="urn:switchyard-config:switchyard:2.0" name="svs.kreator"

                targetNamespace="urn:com.domain:svs.kreator:1.0">

                  <sca:composite name="svs.kreator" targetNamespace="urn:com.domain:svs.kreator:1.0">

                    <sca:component name="MyAccountService">

                      <bean:implementation.bean class="com.domain.svs.kreator.MyAccountServiceBean"/>

                      <sca:service name="MyAccountService">

                        <sca:interface.java interface="com.domain.svs.kreator.MyAccountService"/>

                      </sca:service>

                      <sca:reference name="SvsResource">

                        <sca:interface.java interface="com.domain.svs.kreator.SvsResource"/>

                      </sca:reference>

                    </sca:component>

                    <sca:reference name="SvsAccountReference" multiplicity="0..1" promote="MyAccountService/SvsResource">

                      <sca:interface.java interface="com.domain.svs.kreator.SvsAccountClient"/>

                      <resteasy:binding.rest name="rest1">

                        <resteasy:interfaces>com.domain.svs.kreator.SvsResource</resteasy:interfaces>

                        <resteasy:address>https://www.myserviceprovider.abc/en/index.php</resteasy:address>

                      </resteasy:binding.rest>

                    </sca:reference>

                  </sca:composite>

                  <sy:transforms>

                  <trfm:transform.json

                            from="java:com.domain.svs.kreator.SvsAccount"

                            to="{urn:com.domain:svs.kreator:1.0}svsAccount"/>

                            </sy:transforms>

                </sy:switchyard>

                 

                The error is:

                 

                aused by: org.jboss.resteasy.client.exception.ResteasyClientException: Unexpected exception type

                  at org.jboss.resteasy.client.exception.mapper.ApacheHttpClient4ExceptionMapper.toException(ApacheHttpClient4ExceptionMapper.java:73)

                  at org.jboss.resteasy.client.exception.mapper.ApacheHttpClient4ExceptionMapper.toException(ApacheHttpClient4ExceptionMapper.java:59)

                  at org.switchyard.component.resteasy.util.ClientInvoker.invoke(ClientInvoker.java:341)

                  at org.switchyard.component.resteasy.OutboundHandler.handleMessage(OutboundHandler.java:144)

                  ... 113 more

                Caused by: java.lang.RuntimeException: could not find writer for content-type application/json type: com.domain.svs.kreator.SvsAccount

                  at org.jboss.resteasy.client.ClientRequest.writeRequestBody(ClientRequest.java:470)

                  at org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.writeRequestBodyToOutputStream(ApacheHttpClient4Executor.java:393)

                  at org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.buildEntity(ApacheHttpClient4Executor.java:360)

                  at org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.loadHttpMethod(ApacheHttpClient4Executor.java:332)

                  at org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor.execute(ApacheHttpClient4Executor.java:180)

                  at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:39)

                  at org.jboss.resteasy.plugins.interceptors.encoding.AcceptEncodingGZIPInterceptor.execute(AcceptEncodingGZIPInterceptor.java:40)

                  at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:45)

                  at org.jboss.resteasy.client.ClientRequest.execute(ClientRequest.java:444)

                  at org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:688)

                  at org.switchyard.component.resteasy.util.ClientInvoker.invoke(ClientInvoker.java:335)

                  ... 114 more

                 

                Any idea what I am doing wrong?

                • 5. Re: Resteasy client problems
                  magick93

                  The transformation tags dont make a difference. I have removed them and still get the same error.

                   

                  It seems to be something to do with RestEasy.

                   

                  These are the rest easy dependencies I am using. Am I missing something?

                  Selection_042.png

                  • 6. Re: Resteasy client problems
                    magick93