Java spring boot启动时抛出“方法名必须是令牌”异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38891866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
when spring boot startup,throw out the "method names must be tokens" exception
提问by discipline19810128
When spring boot startup,throw out the method names must be tokens
exception
spring boot启动时抛出method names must be tokens
异常
2016-08-11 16:53:54.499 INFO 14212 --- [0.1-8888-exec-1] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:462) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:994) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_72]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_72]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_72]
2016-08-11 16:53:58.885 INFO 14212 --- [0.1-8888-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-08-11 16:53:58.888 INFO 14212 --- [0.1-8888-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2016-08-11 16:53:58.922 INFO 14212 --- [0.1-8888-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 30 ms
[email protected]
Who know why throw out Invalid character found in method name. HTTP method names must be tokens
exception.
谁知道为什么抛出Invalid character found in method name. HTTP method names must be tokens
异常。
回答by Night White
The same problem.
同样的问题。
cmd -> netstat -ano then find the port your have used(e.g 8888)
I find a process try send package not Http request to my 8888 port, so the tomcat throw the method names must be tokens
Exception.
我发现一个进程尝试向我的 8888 端口发送包而不是 Http 请求,所以 tomcat 抛出method names must be tokens
异常。
you can:
你可以:
change server port;
find the process and kill it;
更改服务器端口;
找到进程并杀死它;
回答by Panchito91
This exception can occur when you try to execute https request from client on endpoint which isn't https enabled. Client will encrypt request data when server is expecting raw data.
当您尝试在未启用 https 的端点上执行来自客户端的 https 请求时,可能会发生此异常。当服务器需要原始数据时,客户端将加密请求数据。
Change https:// to http:// in your client url.
将客户端 URL 中的 https:// 更改为 http://。
回答by rwenz3l
Another Case: SpringBoot and Tomcat use port 8080 or 8888 by default. I had a Jupyter Notebook running at the same time which has a token in it's url path and some random characters. Anyway: The Notebook was still trying to make requests when the jupyter notebook server was down.
另一种情况:SpringBoot 和 Tomcat 默认使用 8080 或 8888 端口。我有一个同时运行的 Jupyter Notebook,它的 url 路径中有一个令牌和一些随机字符。无论如何:当 jupyter notebook 服务器关闭时,Notebook 仍在尝试发出请求。
If you encounter this error: Check if you have another Application running that is either spawning a webserver or talking to a webserver on such ports.
如果您遇到此错误:检查您是否正在运行另一个应用程序,该应用程序正在生成网络服务器或与此类端口上的网络服务器通信。
回答by Deepak Malav
Try with changing your URL from https to http.
尝试将您的 URL 从 https 更改为 http。