I tried to create a feign client for my REST service controller in Spring.

@PostMapping("/search")
public Page<MeasureDto> searchMeasures(@RequestBody MeasureDto example, Pageable pageable) {
    ...
}

The client looks like this:

@PostMapping("/search")
public Page<MeasureDto> searchMeasures(@RequestHeader("apiKey") String apiKey, @RequestBody MeasureDto example, Pageable pageable);

Following exception is thrown when running a test:

Caused by: java.lang.IllegalStateException: Method has too many Body parameters: public abstract org.springframework.data.domain.Page com.foo.bar.jobservice.client.MeasureServiceClient.searchMeasures(java.lang.String,com.example.foo.jobservice.client.dto.MeasureDto,org.springframework.data.domain.Pageable)

What I already know/tried:

There is a closed issue on github: https://github.com/spring-cloud/spring-cloud-netflix/issues/556

The issue with the commit that should have resolved the problem:

https://github.com/spring-cloud/spring-cloud-openfeign/issues/26

The commit:

https://github.com/spring-cloud/spring-cloud-openfeign/commit/6e0e63644ba34193f03c2cd74391cac73b9bfdb4

What i configured:

import feign.codec.Encoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.support.PageJacksonModule;
import org.springframework.cloud.openfeign.support.PageableSpringEncoder;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@EnableFeignClients
@Configuration
public class FeignConfig {

    @Bean
    public PageJacksonModule pageJacksonModule() {
        return new PageJacksonModule();
    }

    @Autowired
    private ObjectFactory<HttpMessageConverters> messageConverters;

    @Bean
    public Encoder feignEncoder() {
        return new PageableSpringEncoder(new SpringEncoder(messageConverters));
    }
}

Still not working.

What I am using:

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>

<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.2.3.RELEASE</version>

What am I doing wrong?

Comment From: ryanjbaxter

Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

Comment From: manuelwaltschek

https://github.com/manuelwaltschek/mre.git

spring/spring-cloud-openfeign/375-pageable-not-working/parent/client/src/test/java/com/example/client/HelloServiceClientTest.java

Problem is... it works in this example, or did I miss something?

I have basically the same configuration in production

Comment From: manuelwaltschek

Could it be that there is a configuration problem? When I debug locally on the non-functional code the

@Bean public PageJacksonModule pageJacksonModule() { return new PageJacksonModule(); }

is never called

Comment From: manuelwaltschek

I updated the example. Now it is properly not working when you start up the client service. Also when you run the test it fails now.

Comment From: manuelwaltschek

If this is not a feature. Can you give me examples how to resolve this on the client side? For example how to write a wrapper for this so that the controller Interface on the server-side can stay the same.

Comment From: manuelwaltschek

I think this example confirms what was written in this comment:

https://github.com/spring-cloud/spring-cloud-openfeign/issues/26#issuecomment-487076748

How do I parse it with AnnotatedParameterProcessor?

Comment From: manuelwaltschek

I am sending the Pageable in url query params now, using the following interface:

@PostMapping("/search")
    public Page<HelloDto> searchHellos(@RequestHeader("apiKey") String apiKey, @RequestBody HelloDto example, @SpringQueryMap Pageable pageable);

Comment From: OlgaMaciaszek

Thanks for providing the workaround @manuelwaltschek