odrotbohm/rest-microservices

Ambiguous handler methods mapped for HTTP path 'http://localhost:8081/stores/search/findByAddressLocationNear'

Sudip7 opened this issue · 1 comments

Hi,

I was attempting a dry run to test your code. I followed the instructions provided in the readme file. If I ran store service and customer service individually there is no problem. But each time, I tried to run them together I got above error. But the test case StoreRepositoryIntegrationTests working absolutely fine.

I am quite new to the cloud, eureka but have a bit experience in spring boot technology. For your reference have attached stack trace.

2016-07-31` 11:23:54.431 ERROR 5268 --- [nio-8081-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path 'http://localhost:8081/stores/search/findByAddressLocationNear': {public org.springframework.http.ResponseEntity org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.util.MultiValueMap,java.lang.String,org.springframework.data.rest.webmvc.support.DefaultedPageable,org.springframework.data.domain.Sort,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler), public org.springframework.http.ResponseEntity org.springframework.data.rest.webmvc.RepositorySearchController.headForSearch(org.springframework.data.rest.webmvc.RootResourceInformation,java.lang.String)}] with root cause

java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path 'http://localhost:8081/stores/search/findByAddressLocationNear': {public org.springframework.http.ResponseEntity org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.util.MultiValueMap,java.lang.String,org.springframework.data.rest.webmvc.support.DefaultedPageable,org.springframework.data.domain.Sort,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler), public org.springframework.http.ResponseEntity org.springframework.data.rest.webmvc.RepositorySearchController.headForSearch(org.springframework.data.rest.webmvc.RootResourceInformation,java.lang.String)}
        at 
....

M I missing something??? Please assist!!!

Short solution: downgrading parent pom to Spring Boot 1.4 M1 or upgrading to Spring Boot 1.4 M3 as suggested http://stackoverflow.com/questions/37276725/why-do-i-have-ambiguous-handler-methods-mapped-for-http-path-in-my-spring-boot-r.

moving out from Embedded MongoDB

If like to upgrade to standalone MongoDB as per requirement here is the solution.

a. removing embedded MongoDB dependency

Remove the following dependency from store service module

<dependency> <groupId>de.flapdoodle.embed</groupId> <artifactId>de.flapdoodle.embed.mongo</artifactId> <scope>runtime</scope> </dependency>

b. adding spring boot autoconfigure dependency

Add the below dependency in store service module.

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-autoconfigure --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-autoconfigure</artifactId> <version>1.4.0.RELEASE</version> </dependency>

c. stating the MongoDB server(standalone/remote) before running the store service application

As we are longer using embedded MongoDB, MongoDB server needs to be started prior to
running of store service module.