Tomcat升级到9.0.x, 发现启动Tomcat后,在Tomcat日志中不段出现
十月 15, 2023 1:04:51 上午 org.apache.coyote.http11.Http11Processor prepareResponse
警告: HTTP响应头信息[Last-Modified] 值[星期日, 15 十月 2023 01:02:08 GMT],由于无效已从响应中移除
java.lang.IllegalArgumentException: 代码点[26,143]处的Unicode字符[星]无法编码,因为它超出了允许的0到255范围。
at org.apache.tomcat.util.buf.MessageBytes.toBytesSimple(MessageBytes.java:286)
at org.apache.tomcat.util.buf.MessageBytes.toBytes(MessageBytes.java:259)
at org.apache.coyote.http11.Http11OutputBuffer.write(Http11OutputBuffer.java:389)
at org.apache.coyote.http11.Http11OutputBuffer.sendHeader(Http11OutputBuffer.java:368)
at org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1050)
at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:376)
at org.apache.coyote.Response.action(Response.java:209)
at org.apache.coyote.Response.sendHeaders(Response.java:437)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:291)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:271)
at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:120)
at com.opensymphony.webwork.dispatcher.FilterDispatcher.copy(FilterDispatcher.java:321)
at com.opensymphony.webwork.dispatcher.FilterDispatcher.findStaticResource(FilterDispatcher.java:280)
at com.opensymphony.webwork.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:186)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:39)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at com.opensymphony.webwork.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:670)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1790)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:750)
英文的话类似
java.lang.IllegalArgumentException: The Unicode character [СЃ] at code point [1,089] cannot be encoded as it is outside the permitted range of 0 to 255
在stackOverFlow看到类似的问题,但没有解决办法, 但在其他相似问题有人提示让Tomcat 日志使用英文的提示
经此提示, 在windows版的Tomcat catalina.bat, 找到
set "JAVA_OPTS=%JAVA_OPTS% %JSSE_OPTS%"
改成
set "JAVA_OPTS=%JAVA_OPTS% %JSSE_OPTS%" -Duser.language=en -Duser.region=US
或是Linux版 Tomcat catalina.sh, 找到
JAVA_OPTS="$JAVA_OPTS $JSSE_OPTS"
改成
JAVA_OPTS="$JAVA_OPTS $JSSE_OPTS -Duser.language=en -Duser.region=US"
然后重启Tomcat, 警告消失