Announcement Announcement Module
No announcement yet.
HttpInvoker inbound gateway : interface invocation throws NoSuchMethodException Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • HttpInvoker inbound gateway : interface invocation throws NoSuchMethodException

    Hi all,

    I try to run a http invoker gateway as a front-end for my spring integration bus. My client application see a Java interface, let's call it ContractService, with a method in this interface called getContract(String id).

    When I configure a HttpInvoker Inbound Gateway like this :
    HTML Code:
    <httpinvoker:inbound-gateway id="inboundGateway"
    		request-channel="getContractRequestChannel" reply-channel="contractChannel"
    		request-timeout="30000" reply-timeout="10000" />
    I end up with a NoSuchMethodException exception :
    org.springframework.remoting.RemoteInvocationFailureException: Invocation of method [public abstract java.lang.Object org.springframework.integration.gateway.MessagingGateway.sendAndReceive(java.lang.Object)] failed in HTTP invoker remote service at [localhost:8080/MyCompanyBus/inboundGateway]; nested exception is java.lang.NoSuchMethodException: $Proxy2.sendAndReceive(java.lang.Object)
    	at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(
    Normal, you would say, as I define nowhere the ContractService interface...
    I tried to replace, from the client point of view, the ContractService interface with the org.springframework.integration.gateway.MessagingG ateway and invoke the sendAndReceive(Object) method, as the gateway implement that interface, and I end up with the same exception.

    The only way I succeed is when defining an HttpInvokerServiceExporter with the business interface :
    HTML Code:
    <beans:bean name="inboundGateway" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
    		<beans:property name="service" ref="contractServiceGateway"/>
    		<beans:property name="serviceInterface" value="com.mycompany.bus.service.ContractService"/>
    And to redirect internally into a SimpleMessagingGateway.

    So what is the correct way to use the HttpInvokerGateway ? why do I receive the NoSuchMethodException ?

    Thanks for your help,

    Jérémie Grodziski.

    P.S : the client configuration is right, as the exception is thrown from the server side.

  • #2
    Can you please show your client side configuration?


    • #3
      Here is the beans.xml config :
      HTML Code:
      <bean id="contractService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
      <property name="serviceUrl" value="httpsemicolon//localhost:8080/MyCompanyBus/inboundGateway"/>
      <property name="serviceInterface" value="com.mycompany.bus.service.ContractService"/>
      The java part is a classic :
      public static void main(String[] args) throws Exception{
      		ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:beans-test.xml");
      		ContractService contract = (ContractService)ctx.getBean("contractService");
      		contract.getContract(new GetContractRequest("1","1"));
      I precise that replacing the server side spring conf with a HttpInvokerServiceExporter instead of the gateway makes things work perfectly. I also precise that I ran the client part inside and outside Eclipse that run the tomcat server to eliminate the eclipse role in some classloading problem.


      Jérémie Grodziski.


      • #4
        OK. I see what's happening now. You should use the HttpInvokerOutboundGateway on the client side. That will expect the same interface that is exposed by the inbound-gateway.

        The schema-based configuration will be similar to this:
        <httpinvoker:outbound-gateway id="outboundGateway"