简体   繁体   English

错误 java.lang.IllegalArgumentException:参数类型的名称 [java.lang.String]

[英]Error java.lang.IllegalArgumentException: Name for argument type [java.lang.String]

I've been struggling to find out the solution with this error for 2 weeks. 2 周以来,我一直在努力寻找解决此错误的方法。 Could you help me what happened你能帮我看看发生了什么吗

Here is the error stack trace:这是错误堆栈跟踪:

"java.lang.IllegalArgumentException: Name for argument type [java.lang.String] not available, and parameter name information not found in class file either.\\r\\n\\tat org.springframework.util.Assert.notNull(Assert.java:112)\\r\\n\\tat org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.updateNamedValueInfo(AbstractNamedValueMethodArgumentResolver.java:138)\\r\\n\\tat org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.getNamedValueInfo(AbstractNamedValueMethodArgumentResolver.java:117)\\r\\n\\tat org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:84)\\r\\n\\tat org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77)\\r\\n\\tat org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162)\\r\\n\\tat org.springfra “java.lang.IllegalArgumentException:参数类型 [java.lang.String] 的名称不可用,并且在类文件中也找不到参数名称信息。\\r\\n\\tat org.springframework.util.Assert.notNull(Assert. java:112)\\r\\n\\tat org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.updateNamedValueInfo(AbstractNamedValueMethodArgumentResolver.java:138)\\r\\n\\tat org.springframework.web.method.annotation.MethodArgumentResolver.updateNamedValueInfo(AbstractNamedValueMethodArgumentResolver.java:138)\\r\\n\\tat org.springframework.web.method.annotation.MethodArgumentResolver.updateNamedValueInfo AbstractNamedValueMethodArgumentResolver.java:117)\\r\\n\\tat org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:84)\\r\\n\\tat org.methodspringframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:84)\\r\\n\\tat org.methodspringframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver. resolveArgument(HandlerMethodArgumentResolverComposite.java:77)\\r\\n\\tat org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162)\\r\\n\\tat org.springfra mework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:123)\\r\\n\\tat org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)\\r\\n\\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)\\r\\n\\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)\\r\\n\\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)\\r\\n\\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)\\r\\n\\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)\\r\\n\\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)\\r\\n\\tat org.springframework.web.servlet.Fr mework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:123)\\r\\n\\tat org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)\\r \\n\\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)\\r\\n\\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter。 handleInternal(RequestMappingHandlerAdapter.java:686)\\r\\n\\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)\\r\\n\\tat org.springframework.web.servlet. DispatcherServlet.doDispatch(DispatcherServlet.java:925)\\r\\n\\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)\\r\\n\\tat org.springframework.web.servlet.FrameworkServlet。 processRequest(FrameworkServlet.java:936)\\r\\n\\tat org.springframework.web.servlet.Fr ameworkServlet.doGet(FrameworkServlet.java:827)\\r\\n\\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:735)\\r\\n\\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)\\r\\n\\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:848)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1496)\\r\\n\\tat org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:82)\\r\\n\\tat org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:294)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1484)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\\r\\n\\tat org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)\\r\\n\\tat org.springframework.security.web.access.in ameworkServlet.doGet(FrameworkServlet.java:827)\\r\\n\\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:735)\\r\\n\\tat org.springframework.web.servlet.FrameworkServlet.service( FrameworkServlet.java:812)\\r\\n\\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:848)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:第 684 章82)\\r\\n\\tat org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:294)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java: 1484)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\\r\\n\\tat org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke FilterSecurityInterceptor.java:118)\\r\\n\\tat org.springframework.security.web.access.in tercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilt tercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security。 web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework。 security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org. springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilt er(SecurityContextHolderAwareRequestFilter.java:54)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125) er(SecurityContextHolderAwareRequestFilter.java:54)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.savedrequest。 RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web。 authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security。 web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org. springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125) \\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)\\r\\n\\tat org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)\\r\\n\\tat org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)\\r\\n\\tat org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1476)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)\\r\\n\\tat org.eclipse.jetty.server.handler.ScopedHandler. \\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java: 87)\\r\\n\\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)\\r\\n\\tat org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java: 192)\\r\\n\\tat org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)\\r\\n\\tat org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) \\r\\n\\tat org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1476) \\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)\\r\\n\\tat org.eclipse.jetty.server.handler.ScopedHandler。 handle(ScopedHandler.java:137)\\r\\n\\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)\\r\\n\\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)\\r\\n\\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)\\r\\n\\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)\\r\\n\\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)\\r\\n\\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)\\r\\n\\tat org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)\\r\\n\\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)\\r\\n\\tat org.eclipse.jetty.server.Server.handle(Server.java:370)\\r\\n\\tat org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)\\r\\n\\tat 句柄(ScopedHandler.java:137)\\r\\n\\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)\\r\\n\\tat org.eclipse.jetty.server.session.SessionHandler。 doHandle(SessionHandler.java:231)\\r\\n\\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)\\r\\n\\tat org.eclipse.jetty.servlet.ServletHandler。 doScope(ServletHandler.java:428)\\r\\n\\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)\\r\\n\\tat org.eclipse.jetty.server.handler。 ContextHandler.doScope(ContextHandler.java:1020)\\r\\n\\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)\\r\\n\\tat org.eclipse.jetty.server。 handler.HandlerCollection.handle(HandlerCollection.java:154)\\r\\n\\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)\\r\\n\\tat org.eclipse.jetty。 server.Server.handle(Server.java:370)\\r\\n\\tat org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)\\r\\n\\tat org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)\\r\\n\\tat org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)\\r\\n\\tat org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)\\r\\n\\tat org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)\\r\\n\\tat org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)\\r\\n\\tat org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)\\r\\n\\tat org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)\\r\\n\\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)\\r\\n\\tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)\\r\\n\\tat java.lang.Thread.run(Thread.java:748)\\r\\n" org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)\\r\\n\\tat org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)\\r\\n\\tat org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)\\r\\n\\tat org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)\\r\\n\\tat org. eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)\\r\\n\\tat org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)\\r\\n\\tat org. eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)\\r\\n\\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)\\r\\n\\ tat org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)\\r\\n\\tat java.lang.Thread.run(Thread.java:748)\\r\\n"

You are most likely trying to past argument as a String somewhere where it should not be accepting String as a parameter or could be not accepting any parameters at all.您很可能试图将参数作为 String 传递给不应接受 String 作为参数或根本不接受任何参数的地方。

As one of the comment said, can you post your codes here?正如其中一位评论所说,您可以在这里发布您的代码吗? The logs are not telling as well which of your specific class is having an exception.日志也没有说明您的特定类中的哪个有异常。

I suspect you have some Spring MVC controllers and expect that Spring matches controller method arguments and request parameters by name automatically.我怀疑您有一些 Spring MVC 控制器,并希望 Spring 自动按名称匹配控制器方法参数和请求参数。

According to this article enter link description here this only works if your code has been compiled with debugging information (javac -g options).根据本文在此处输入链接描述,这仅在您的代码已使用调试信息(javac -g 选项)编译时才有效。

I've also a hard time with this issue.我也很难解决这个问题。 It worked in my IDE, but not when deploying an ant build to a tomcat.它在我的 IDE 中有效,但在将 ant 构建部署到 tomcat 时无效。 When I tried to remote debug the tomcat and therefore added the javac debug options, it suddenly worked.当我尝试远程调试 tomcat 并因此添加 javac 调试选项时,它突然起作用了。 However, i did not see the relation of the debug option and the issue I was looking for ;-)但是,我没有看到调试选项和我正在寻找的问题之间的关系;-)

实际上,这里 String 类型不可用,这意味着如果我们提供参数:@Requestparam(value = "myString") String myString 如果我们像 @Requestparam String myString 这样提供它,很可能会得到该错误。

We faced the same error when the method missed to add @RequestParam annotation against the string.当该方法未针对字符串添加 @RequestParam 注释时,我们遇到了同样的错误。 The error is generated when we started to use the Ant Build through Jenkins.这个错误是我们开始通过Jenkins使用Ant Build时产生的。 When export WAR file through Eclipse IDE, it will not arise.通过Eclipse IDE导出WAR文件时不会出现。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.IllegalArgumentException:“json”参数必须是以下实例:[class java.lang.String, class [B - java.lang.IllegalArgumentException: 'json' argument must be an instance of: [class java.lang.String, class [B java.lang.illegalargumentexception 无法将 java.lang.string 字段设置为 java.lang.String - java.lang.illegalargumentexception cannot set java.lang.string field to java.lang.String java.lang.IllegalArgumentException:参数类型不匹配 - java.lang.IllegalArgumentException: argument type mismatch java.lang.IllegalArgumentException:字符串数组上的参数类型不匹配 - java.lang.IllegalArgumentException: argument type mismatch on string array java.lang.IllegalArgumentException:找到了多个参数类型候选:[java.lang.String]和[java.lang.Long] - java.lang.IllegalArgumentException: Found more than one parameter type candidate: [java.lang.String] and [java.lang.Long] java.lang.IllegalArgumentException:name - java.lang.IllegalArgumentException: name Java &&错误“未为参数类型java.lang.String,java.lang.String定义运算符&&” - Java && Error “The operator && is undefined for the argument type(s) java.lang.String, java.lang.String” 错误:java.lang.IllegalArgumentException - Error: java.lang.IllegalArgumentException Java RMI提供java.lang.IllegalArgumentException:参数类型不匹配 - java RMI is giving java.lang.IllegalArgumentException: argument type mismatch java.lang.IllegalArgumentException:错误的类:类java.lang.String - java.lang.IllegalArgumentException: Bad class: class java.lang.String
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM