title: Getting code error 500 while adding new Service in Jhipster
body: <p>I'm developing a Jhipster app and I'm trying to add a new service. This service should return a list of objects "<strong>Request</strong>" (that has an attribute <strong>id</strong> (Long), <strong>content</strong> (String).</p>
  
  <p>I would like to search a <strong>Request</strong> by <strong>content</strong> with a <strong>@PathVariable</strong>.
  I am using Spring Framework.</p>
  
  <p>This is RequestResource.java method.</p>
  
  <pre><code>@GetMapping(value = "/requests/{content}")
      @Timed
      public ResponseEntity&lt;List&lt;Request&gt;&gt; searchForRequest(@PathVariable String content) {
          log.debug("REST request to get Request : {}", content);
          List&lt;Request&gt; requestsFounded = searchService.searchRequests(content);
          return ResponseUtil.wrapOrNotFound(Optional.ofNullable(requestsFounded));
      }
  </code></pre>
  
  <p>This is SearchService.java method.</p>
  
  <pre><code>private RequestRepository requestRepository;
  
      @Transactional(readOnly = true)
      public List&lt;Request&gt; searchRequests(String content){
          log.debug("REST requests to search for requests based on content given input");
          List&lt;Request&gt; result = requestRepository.findAllByContent(content);
          return result;
      }
  </code></pre>
  
  <p>and finally this is the RequestRepository.java</p>
  
  <pre><code>@SuppressWarnings("unused")
  public interface RequestRepository extends JpaRepository&lt;Request,Long&gt; {
  
      List&lt;Request&gt; findAllByContent(String content);
  
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>EDIT:</p>
  
  <pre><code>java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path 'http://localhost:8080/api/requests/ciao': {public org.springframework.http.ResponseEntity it.mobimentum.businessrequest.web.rest.RequestResource.searchForRequest(java.lang.String), public org.springframework.http.ResponseEntity it.mobimentum.businessrequest.web.rest.RequestResource.getRequest(java.lang.Long)}
  at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:367)
  at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:314)
  at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:61)
  at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:352)
  at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1160)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:940)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
  at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
  at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
  at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
  at com.codahale.metrics.servlet.AbstractInstrumentedFilter.doFilter(AbstractInstrumentedFilter.java:111)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:110)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
  at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
  at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at it.mobimentum.businessrequest.security.jwt.JWTFilter.doFilter(JWTFilter.java:36)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
  at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
  at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
  at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
  at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
  at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
  at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
  at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
  at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
  at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
  at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
  at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
  at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119)
  at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
  at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
  at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
  at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
  at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
  at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
  at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
  at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
  at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
  at io.undertow.server.Connectors.executeRootHandler(Connectors.java:211)
  at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:809)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)
  
  2017-06-21 12:05:05.376  WARN 8096 --- [  XNIO-2 task-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path 'http://localhost:8080/api/requests/ciao': {public org.springframework.http.ResponseEntity it.mobimentum.businessrequest.web.rest.RequestResource.searchForRequest(java.lang.String), public org.springframework.http.ResponseEntity it.mobimentum.businessrequest.web.rest.RequestResource.getRequest(java.lang.Long)}
  </code></pre>
  
  <p>EDIT 2 this is RequestResource.java:</p>
  
  <pre><code>package it.mobimentum.businessrequest.web.rest;
  
  import com.codahale.metrics.annotation.Timed;
  import it.mobimentum.businessrequest.domain.Request;
  
  import it.mobimentum.businessrequest.repository.RequestRepository;
  import it.mobimentum.businessrequest.web.rest.util.HeaderUtil;
  import io.github.jhipster.web.util.ResponseUtil;
  import it.mobimentum.businessrequest.security.AuthoritiesConstants;
  import it.mobimentum.businessrequest.service.SearchService;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.http.ResponseEntity;
  import org.springframework.web.bind.annotation.*;
  
  import java.net.URI;
  import java.net.URISyntaxException;
  
  import java.util.List;
  import java.util.Optional;
  import javax.inject.Inject;
  import org.springframework.security.access.annotation.Secured;
  
  /**
   * REST controller for managing Request.
   */
  @RestController
  @RequestMapping("/api")
  public class RequestResource {
  
      private final Logger log = LoggerFactory.getLogger(RequestResource.class);
  
      private static final String ENTITY_NAME = "request";
  
      private final RequestRepository requestRepository;
  
      @Inject
      private SearchService searchService;
  
      public RequestResource(RequestRepository requestRepository) {
          this.requestRepository = requestRepository;
      }
  
      /**
       * POST  /requests : Create a new request.
       *
       * @param request the request to create
       * @return the ResponseEntity with status 201 (Created) and with body the new request, or with status 400 (Bad Request) if the request has already an ID
       * @throws URISyntaxException if the Location URI syntax is incorrect
       */
      @PostMapping("/requests")
      @Timed
      @Secured({AuthoritiesConstants.PRESIDENT, AuthoritiesConstants.ADMIN, AuthoritiesConstants.USER, AuthoritiesConstants.VICE_PRESIDENT})
      public ResponseEntity&lt;Request&gt; createRequest(@RequestBody Request request) throws URISyntaxException {
          /**
           * Imposto la data di creazione al momento attuale, specifico, in cui
           * essa viene gestita.
           */
          /*CustomUser customUser = new CustomUser();
          customUser.setUsername(SecurityUtils.getCurrentUserLogin());
          request.setCreationDate(LocalDate.now());
          request.setVisible(true);
          request.setAuthor(customUser);*/
          log.debug("REST request to save Request : {}", request);
          if (request.getId() != null) {
              return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "idexists", "A new request cannot already have an ID")).body(null);
          }
          Request result = requestRepository.save(request);
          return ResponseEntity.created(new URI("/api/requests/" + result.getId()))
              .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
              .body(result);
      }
  
      /**
       * PUT  /requests : Updates an existing request.
       *
       * @param request the request to update
       * @return the ResponseEntity with status 200 (OK) and with body the updated request,
       * or with status 400 (Bad Request) if the request is not valid,
       * or with status 500 (Internal Server Error) if the request couldn't be updated
       * @throws URISyntaxException if the Location URI syntax is incorrect
       */
      @PutMapping("/requests")
      @Timed
      @Secured({AuthoritiesConstants.PRESIDENT, AuthoritiesConstants.ADMIN, AuthoritiesConstants.VICE_PRESIDENT})
      public ResponseEntity&lt;Request&gt; updateRequest(@RequestBody Request request) throws URISyntaxException {
          log.debug("REST request to update Request : {}", request);
          if (request.getId() == null) {
              return createRequest(request);
          }
          Request result = requestRepository.save(request);
          return ResponseEntity.ok()
              .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, request.getId().toString()))
              .body(result);
      }
  
      /**
       * GET  /requests : get all the requests.
       *
       * @return the ResponseEntity with status 200 (OK) and the list of requests in body
       */
      @GetMapping("/requests")
      @Timed
      @Secured({AuthoritiesConstants.PRESIDENT, AuthoritiesConstants.ADMIN, AuthoritiesConstants.USER, AuthoritiesConstants.VICE_PRESIDENT})
      public List&lt;Request&gt; getAllRequests() {
          log.debug("REST request to get all Requests");
          return requestRepository.findAll();
      }
  
      /**
       * GET  /requests/:id : get the "id" request.
       *
       * @param content the content of the request to retrieve
       * @return the ResponseEntity with status 200 (OK) and with body the request, or with status 404 (Not Found)
       */
  
      @GetMapping("/search/{content}")
      @Timed
      public ResponseEntity&lt;List&lt;Request&gt;&gt; searchForRequest(@PathVariable String content) {
          log.debug("REST request to get Request : {}", content);
          List&lt;Request&gt; requestsFounded = searchService.searchRequests(content);
          return ResponseUtil.wrapOrNotFound(Optional.ofNullable(requestsFounded));
      }
  
      /**
       * GET  /requests/:id : get the "id" request.
       *
       * @param id the id of the request to retrieve
       * @return the ResponseEntity with status 200 (OK) and with body the request, or with status 404 (Not Found)
       */
      @GetMapping("/requests/{id}")
      @Timed
      public ResponseEntity&lt;Request&gt; getRequest(@PathVariable Long id) {
          log.debug("REST request to get Request : {}", id);
          Request request = requestRepository.findOne(id);
          return ResponseUtil.wrapOrNotFound(Optional.ofNullable(request));
      }
  
      /**
       * DELETE  /requests/:id : delete the "id" request.
       *
       * @param id the id of the request to delete
       * @return the ResponseEntity with status 200 (OK)
       */
      @DeleteMapping("/requests/{id}")
      @Timed
      @Secured({AuthoritiesConstants.PRESIDENT, AuthoritiesConstants.ADMIN, AuthoritiesConstants.VICE_PRESIDENT})
      public ResponseEntity&lt;Void&gt; deleteRequest(@PathVariable Long id) {
          log.debug("REST request to delete Request : {}", id);
          requestRepository.delete(id);
          return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
      }
  
  }
  </code></pre>