Tomcat 8 cookie domain validation problem

Keywords: Operation & Maintenance Java Apache Tomcat xml

The error code is as follows

Type Exception Report

Message An invalid domain [127.0.0.1:8080] was specified for this cookie

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

java.lang.IllegalArgumentException: An invalid domain [127.0.0.1:8080] was specified for this cookie
	org.apache.tomcat.util.http.Rfc6265CookieProcessor.validateDomain(Rfc6265CookieProcessor.java:198)
	org.apache.tomcat.util.http.Rfc6265CookieProcessor.generateHeader(Rfc6265CookieProcessor.java:145)
	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)
	com.vrv.im.filter.SSOFilter.addCookie(SSOFilter.java:298)
	com.vrv.im.filter.SSOFilter.doFilter(SSOFilter.java:165)

This is because your local version of Tomcat is too high. You can find the context.xml installation directory of tomcat.

Add code to specify CookieProcessor as Legacy CookieProcessor instead of Rfc6265 CookieProcessor

1. Cause analysis:

The domain rules used by Rfc6265 CookieProcessor are as follows
1. Must be composed of characters 1-9, a-z, A-Z,. -(Note that - not)

2. Must be the beginning of a number or letter (so the previous cookie setting is. i5a6.com instead of i5a6.com)

3. Must be the end of a number or letter

Because [127.0.0.1:8080] is used in this case, which contains ":", so hanging.

2. Solutions:

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

<?xml version="1.0" encoding="UTF-8"?>
<!-- The contents of this file will be loaded for each web application -->
<Context>

<!-- Default set of monitored resources. If one of these changes, the    -->
<!-- web application will be reloaded.                                   -->

<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!-- <Manager pathname="" /> -->
<!-- Add code -->
<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor"/>

</Context>

 

Posted by Rollo Tamasi on Sun, 03 Feb 2019 01:51:15 -0800