5 Replies Latest reply on Mar 10, 2011 5:11 AM by Claus Ibsen

    CamelRoute from activemq to cxfrs

    Ludovic Saublains Newbie

      Hi everybody,

       

      I have some problem with my spring camel context route.

       

      I must call a cxfrs method without any parameters but it seems not to work correctly.

       

      My spring rout is like this:

       

      <camel:route id="jmsToCxfrs" trace="true">

       

                  <camel:from uri="activemq:mqA"/>

                   

                  <!-- Use cxf client proxy -->

                  <camel:setHeader headerName="CamelCxfRsUsingHttpAPI">

                      <camel:constant>False</camel:constant>

                  </camel:setHeader>

       

                  <!-- call getXXX method -->

                  <camel:setHeader headerName="operationName">

                      <camel:constant>getXXX</camel:constant>

                  </camel:setHeader>

       

                  <!-- Response is a XXX object -->

                  <camel:setHeader headerName="CamelCxfRsResponseClass">

                      <camel:constant>XXX.class</camel:constant>

                  </camel:setHeader>

       

                  <!-- set body to null (method without any parameters) -->

                 <!-- <camel:setBody>

                      <camel:constant/>

                  </camel:setBody> -->

       

                  <camel:to uri="cxfrs://bean://cxfService"/>         

       

              </camel:route>

       

      But when it want to call my method, I have an exception:

       

      java.lang.NoSuchMethodException: Can find the method getXXX with these parameter

           at org.apache.camel.component.cxf.jaxrs.CxfRsProducer.findRightMethod(CxfRsProducer.java:221)

       

      How can I say to camel that my method don't need any parameters?

       

      Thanks a lot for your help

       

      Edited by: lusa on Mar 10, 2011 7:50 AM

      Comment , camel:setBody to have body to null

        • 1. Re: CamelRoute from activemq to cxfrs
          Ludovic Saublains Newbie

          Hi everybody,

           

          I have test my issue with the org.apache.camel.Processor but I have same error:

           

          <camel:route id="jmsToCxfrs" trace="true">

                      <camel:from uri="activemq:mqA"/>

                      <camel:process ref="cxfProcessor"/>

          </camel:route>

           

          And here are the processor:

          public void process(Exchange exchange) throws Exception {

                  exchange.setPattern(ExchangePattern.InOut);

                  Message inMessage = exchange.getIn();

           

                  inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.FALSE);

                  inMessage.setHeader(CxfConstants.OPERATION_NAME, "getXXX");

                  inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, XXX.class);

                  inMessage.setBody(null);

          }

           

          This produce the same exception:

          java.lang.NoSuchMethodException: Can find the method getXXX with these parameter http://class org.apache.camel.component.jms.JmsMessage

          at org.apache.camel.component.cxf.jaxrs.CxfRsProducer.findRightMethod(CxfRsProducer.java:221).

           

          Is it possible to call a cxfrs method without parameters?

           

          Thanks a lot for your help,

          LuSa

          • 2. Re: CamelRoute from activemq to cxfrs
            Claus Ibsen Master

            Hi

             

            Yeah looks like the source code mandates a parameter. I will log an enhancement.

            • 4. Re: CamelRoute from activemq to cxfrs
              Ludovic Saublains Newbie

              Hi davsclaus ,

               

              Thanks for your reply, for the moment I have make my own patch like this:

               

              In my Processor I have add my own TypeConverter:

               

              public class CXFConverter implements TypeConverter {

               

                  @SuppressWarnings({"unchecked"})

                  @Override

                  public  type, Exchange exchange, Object value) throws NoTypeConversionAvailableException {

                      return convertTo(type, value);

                  }

              }

               

              and I have set it like this:

              ((SpringCamelContext) inMessage.getExchange().getContext()).setTypeConverter(new CXFConverter());

               

              So my custom Processor is now:

               

              public class CXFProcessor implements Processor {

               

                  @Override

                  public void process(Exchange exchange) throws Exception {

                      exchange.setPattern(ExchangePattern.InOut);

                      Message inMessage = exchange.getIn();

               

                      ((SpringCamelContext) inMessage.getExchange().getContext()).setTypeConverter(new CXFConverter());

                      inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.FALSE);

                      inMessage.setHeader(CxfConstants.OPERATION_NAME, "getXXX");

                      inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, XXX.class);

                      inMessage.setBody(null);

                  }

              }

               

              Greetings,

              LuSa

              • 5. Re: CamelRoute from activemq to cxfrs
                Claus Ibsen Master

                Hi

                 

                Thanks for posting the workaround.