java.lang.IllegalArgumentException:Cookie值中存在无效字符[34]

时间:2017-10-11 10:34:32

标签: cookies user-roles kie-workbench tomcat8.5

这是我的tomcat-users文件的样子:

<tomcat-users>
  <role rolename="admin"/>
  <role rolename="analyst"/> 
  <role rolename="user"/>
  <role rolename="kie-server"/>
  <role rolename="developer"/>
  <role rolename="manager"/>

  <user username="w" password="w" roles="admin"/>
  <user username="k" password="k" roles="kie-server"/>  
  <user username="u" password="u" roles="user,developer,analyst"/>
</tomcat-users>

在KIE IDE WORKBENCH中输入正确的凭据后,我收到以下异常:

java.lang.IllegalArgumentException: An invalid character [34] was present in the Cookie value
        org.apache.tomcat.util.http.Rfc6265CookieProcessor.validateCookieValue(Rfc6265CookieProcessor.java:182)
        org.apache.tomcat.util.http.Rfc6265CookieProcessor.generateHeader(Rfc6265CookieProcessor.java:115)
        org.apache.catalina.connector.Response.generateCookieString(Response.java:1019)
        org.apache.catalina.connector.Response.addCookie(Response.java:967)
        org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:386)
        org.uberfire.ext.security.server.SecurityIntegrationFilter.doFilter(SecurityIntegrationFilter.java:61)

1 个答案:

答案 0 :(得分:4)

CookieProcessor是Tomcat 8.0.15中引入的新配置元素。 CookieProcessor元素允许在每个Web应用程序中进行不同的cookie解析配置,或者在默认的 conf / context.xml 文件中进行全局。

根据Apache Tomcat 8 Configuration Reference Version 8.0.47的官方文件:

CookieProcessor的标准实现是: org.apache.tomcat.util.http.LegacyCookieProcessor 。请注意,在未来的Tomcat 8版本中,预计会更改为org.apache.tomcat.util.http.Rfc6265CookieProcessor。

稍后..

根据Apache Tomcat 8 Configuration Reference Version 8.5.23

的官方文件

CookieProcessor的标准实现是org.apache.tomcat.util.http.Rfc6265CookieProcessor

要解决此问题,请在位于%CATALINA_HOME%的conf / context.xml中添加此行(例如,在我的情况下为C:\ apache-tomcat-8.5.20 \ conf \ context.xml):

<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />

这是添加后的样子:

<?xml version="1.0" encoding="UTF-8"?>

<Context reloadable="true">
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
    <Transaction factory="bitronix.tm.BitronixUserTransactionObjectFactory"/>
    <CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />    
</Context>