java.lang.IllegalArgumentException: No @Param annotation found on query method findByToId for parameter null

Spring JIRA | Rob Winch | 3 years ago
  1. 0

    Currently if a Repository is exposed with a finder method, it requires that the \@Param annotation be present otherwise an error similar to the following is returned: {code} public interface MessageRepository extends JpaRepository<Message, Long> { Page<Message> findByToId( Long to, Pageable pageable); } {code} {code} 12:25:39.700 [http-bio-8080-exec-3] ERROR o.s.d.r.w.AbstractRepositoryRestController - No @Param annotation found on query method findByToId for parameter null java.lang.IllegalArgumentException: No @Param annotation found on query method findByToId for parameter null at org.springframework.data.rest.core.invoke.ReflectionRepositoryInvoker.prepareParameters(ReflectionRepositoryInvoker.java:218) ~[spring-data-rest-core-2.0.0.BUILD-SNAPSHOT.jar:na] at org.springframework.data.rest.core.invoke.ReflectionRepositoryInvoker.invokeQueryMethod(ReflectionRepositoryInvoker.java:190) ~[spring-data-rest-core-2.0.0.BUILD-SNAPSHOT.jar:na] at org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:208) ~[spring-data-rest-webmvc-2.0.0.BUILD-SNAPSHOT.jar:na] at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:129) ~[spring-data-rest-webmvc-2.0.0.BUILD-SNAPSHOT.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_40] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_40] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_40] at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_40] at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219) ~[spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) ~[spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827) [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) [servlet-api.jar:na] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) [servlet-api.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) [catalina.jar:7.0.42] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) [catalina.jar:7.0.42] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) [catalina.jar:7.0.42] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) [catalina.jar:7.0.42] at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.42] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) [catalina.jar:7.0.42] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) [tomcat-coyote.jar:7.0.42] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) [tomcat-coyote.jar:7.0.42] at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) [tomcat-coyote.jar:7.0.42] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_40] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_40] at java.lang.Thread.run(Thread.java:724) [na:1.7.0_40] {code} Spring Data is able to figure out the parameter names for querying, so it should also be able to default them for Spring Data Rest. Also note that it currently reports a HTTP 400 Bad Request. However, this should really be a 5xx since it is a server issue. I'm not sure if this is a general issue or isolated. If it is a general issue, then there should probably be a separate ticket created for proper HTTP status code as well.

    Spring JIRA | 3 years ago | Rob Winch
    java.lang.IllegalArgumentException: No @Param annotation found on query method findByToId for parameter null
  2. 0

    Currently if a Repository is exposed with a finder method, it requires that the \@Param annotation be present otherwise an error similar to the following is returned: {code} public interface MessageRepository extends JpaRepository<Message, Long> { Page<Message> findByToId( Long to, Pageable pageable); } {code} {code} 12:25:39.700 [http-bio-8080-exec-3] ERROR o.s.d.r.w.AbstractRepositoryRestController - No @Param annotation found on query method findByToId for parameter null java.lang.IllegalArgumentException: No @Param annotation found on query method findByToId for parameter null at org.springframework.data.rest.core.invoke.ReflectionRepositoryInvoker.prepareParameters(ReflectionRepositoryInvoker.java:218) ~[spring-data-rest-core-2.0.0.BUILD-SNAPSHOT.jar:na] at org.springframework.data.rest.core.invoke.ReflectionRepositoryInvoker.invokeQueryMethod(ReflectionRepositoryInvoker.java:190) ~[spring-data-rest-core-2.0.0.BUILD-SNAPSHOT.jar:na] at org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:208) ~[spring-data-rest-webmvc-2.0.0.BUILD-SNAPSHOT.jar:na] at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:129) ~[spring-data-rest-webmvc-2.0.0.BUILD-SNAPSHOT.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_40] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_40] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_40] at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_40] at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219) ~[spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) ~[spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827) [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) [servlet-api.jar:na] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) [servlet-api.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) [catalina.jar:7.0.42] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) [catalina.jar:7.0.42] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) [catalina.jar:7.0.42] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) [catalina.jar:7.0.42] at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.42] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) [catalina.jar:7.0.42] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) [tomcat-coyote.jar:7.0.42] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) [tomcat-coyote.jar:7.0.42] at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) [tomcat-coyote.jar:7.0.42] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_40] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_40] at java.lang.Thread.run(Thread.java:724) [na:1.7.0_40] {code} Spring Data is able to figure out the parameter names for querying, so it should also be able to default them for Spring Data Rest. Also note that it currently reports a HTTP 400 Bad Request. However, this should really be a 5xx since it is a server issue. I'm not sure if this is a general issue or isolated. If it is a general issue, then there should probably be a separate ticket created for proper HTTP status code as well.

    Spring JIRA | 3 years ago | Rob Winch
    java.lang.IllegalArgumentException: No @Param annotation found on query method findByToId for parameter null
  3. 0

    Why this Hibernate HQL query give me this error message "Name for parameter binding must not be null or empty!"?

    Stack Overflow | 6 days ago | AndreaNobili
    org.springframework.dao.InvalidDataAccessApiUsageException: Name for parameter binding must not be null or empty! For named parameters you need to use @Param for query method parameters on Java versions < 8.; nested exception is java.lang.IllegalArgumentException: Name for parameter binding must not be null or empty! For named parameters you need to use @Param for query method parameters on Java versions < 8.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Error when using Retrofit

    Stack Overflow | 8 months ago | rost_proz
    java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #1) for method VideoApi.getFeaturedVideo
  6. 0

    Retrofit HTTP Get with dynamic URL

    Stack Overflow | 2 years ago | ShahrozKhan91
    java.lang.IllegalArgumentException: AuthApi.getSession: No Retrofit annotation found. (Parameter#1)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      No @Param annotation found on query method findByToId for parameter null

      at org.springframework.data.rest.core.invoke.ReflectionRepositoryInvoker.prepareParameters()
    2. Spring Data REST - Core
      ReflectionRepositoryInvoker.invokeQueryMethod
      1. org.springframework.data.rest.core.invoke.ReflectionRepositoryInvoker.prepareParameters(ReflectionRepositoryInvoker.java:218)[spring-data-rest-core-2.0.0.BUILD-SNAPSHOT.jar:na]
      2. org.springframework.data.rest.core.invoke.ReflectionRepositoryInvoker.invokeQueryMethod(ReflectionRepositoryInvoker.java:190)[spring-data-rest-core-2.0.0.BUILD-SNAPSHOT.jar:na]
      2 frames
    3. Spring Data REST - WebMVC
      RepositorySearchController.executeSearch
      1. org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:208)[spring-data-rest-webmvc-2.0.0.BUILD-SNAPSHOT.jar:na]
      2. org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:129)[spring-data-rest-webmvc-2.0.0.BUILD-SNAPSHOT.jar:na]
      2 frames
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[na:1.7.0_40]
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[na:1.7.0_40]
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[na:1.7.0_40]
      4. java.lang.reflect.Method.invoke(Method.java:606)[na:1.7.0_40]
      4 frames
    5. Spring
      InvocableHandlerMethod.invokeForRequest
      1. org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)[spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      2. org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)[spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      2 frames
    6. Spring MVC
      FrameworkServlet.doGet
      1. org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      2. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      3. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      4. org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      5. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      6. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      7. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      8. org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      8 frames
    7. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:621)[servlet-api.jar:na]
      1 frame
    8. Spring MVC
      FrameworkServlet.service
      1. org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      1 frame
    9. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:728)[servlet-api.jar:na]
      1 frame
    10. Glassfish Core
      CoyoteAdapter.service
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)[catalina.jar:7.0.42]
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)[catalina.jar:7.0.42]
      3. org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)[catalina.jar:7.0.42]
      4. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)[catalina.jar:7.0.42]
      5. org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)[catalina.jar:7.0.42]
      6. org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)[catalina.jar:7.0.42]
      7. org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)[catalina.jar:7.0.42]
      8. org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)[catalina.jar:7.0.42]
      9. org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)[catalina.jar:7.0.42]
      10. org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)[catalina.jar:7.0.42]
      10 frames
    11. Grizzly HTTP
      JIoEndpoint$SocketProcessor.run
      1. org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)[tomcat-coyote.jar:7.0.42]
      2. org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)[tomcat-coyote.jar:7.0.42]
      3. org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)[tomcat-coyote.jar:7.0.42]
      3 frames
    12. Java RT
      Thread.run
      1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[na:1.7.0_40]
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[na:1.7.0_40]
      3. java.lang.Thread.run(Thread.java:724)[na:1.7.0_40]
      3 frames