解决 IllegalArgumentException: 代码点[26,143]处的Unicode字符[星]无法编码,因为它超出了允许的0到255范围 问题

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, 警告消失

相关推荐
2401_8576100330 分钟前
Spring Boot框架:电商系统的技术优势
java·spring boot·后端
希忘auto1 小时前
详解MySQL安装
java·mysql
冰淇淋烤布蕾1 小时前
EasyExcel使用
java·开发语言·excel
拾荒的小海螺1 小时前
JAVA:探索 EasyExcel 的技术指南
java·开发语言
Jakarta EE1 小时前
正确使用primefaces的process和update
java·primefaces·jakarta ee
马剑威(威哥爱编程)1 小时前
哇喔!20种单例模式的实现与变异总结
java·开发语言·单例模式
java—大象2 小时前
基于java+springboot+layui的流浪动物交流信息平台设计实现
java·开发语言·spring boot·layui·课程设计
杨哥带你写代码2 小时前
网上商城系统:Spring Boot框架的实现
java·spring boot·后端
camellias_2 小时前
SpringBoot(二十一)SpringBoot自定义CURL请求类
java·spring boot·后端
布川ku子2 小时前
[2024最新] java八股文实用版(附带原理)---Mysql篇
java·mysql·面试