Results 1 to 4 of 4

Thread: HttpInvoker inbound gateway : interface invocation throws NoSuchMethodException

  1. #1
    Join Date
    Dec 2008
    Posts
    2

    Default 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 :
    Code:
    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(HttpInvokerClientInterceptor.java:154)
    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"/>
    	</beans:bean>
    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. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    Can you please show your client side configuration?

  3. #3
    Join Date
    Dec 2008
    Posts
    2

    Default

    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"/>
    </bean>
    The java part is a classic :
    Code:
    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.

    Thanks.

    Jérémie Grodziski.

  4. #4
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    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:
    Code:
    <httpinvoker:outbound-gateway id="outboundGateway"
                                  url="http://localhost:8080/test"
                                  request-channel="testChannel"/>

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •