WAS Liberty profile java.lang.IllegalArgumentException: Cookie name “Path” is a reserved token

旧巷老猫 提交于 2019-12-12 01:11:04

问题


I am getting following exception when trying to access the deployed war application.

Environment Details: WAS Liberty Profile and IBM JDK 6

<pre>
Exception = java.lang.IllegalArgumentException
Source = com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters
probeid = 1105
Stack Dump = java.lang.IllegalArgumentException: Cookie name "Path" is a reserved token
    at javax.servlet.http.Cookie.<init>(Cookie.java:139)
    at com.ibm.ws.webcontainer.osgi.request.IRequestImpl.getCookies(IRequestImpl.java:147)
    at com.ibm.ws.webcontainer.srt.SRTServletRequest.getCookies(SRTServletRequest.java:1600)
    at com.ibm.ws.webcontainer.security.internal.WebRequestImpl.determineIfRequestHasAuthenticationData(WebRequestImpl.java:155)
    at com.ibm.ws.webcontainer.security.internal.WebRequestImpl.hasAuthenticationData(WebRequestImpl.java:176)
    at com.ibm.ws.webcontainer.security.internal.WebAppSecurityCollaboratorImpl.optionallyAuthenticateUnprotectedResource(WebAppSecurityCollaboratorImpl.java:392)
    at com.ibm.ws.webcontainer.security.internal.WebAppSecurityCollaboratorImpl.performSecurityChecks(WebAppSecurityCollaboratorImpl.java:343)
    at com.ibm.ws.webcontainer.security.internal.WebAppSecurityCollaboratorImpl.preInvoke(WebAppSecurityCollaboratorImpl.java:327)
    at com.ibm.wsspi.webcontainer.collaborator.CollaboratorHelper.preInvokeCollaborators(CollaboratorHelper.java:431)
    at com.ibm.ws.webcontainer.osgi.collaborator.CollaboratorHelperImpl.preInvokeCollaborators(CollaboratorHelperImpl.java:267)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1033)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:81)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:930)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$1.run(DynamicVirtualHost.java:253)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:457)
    at com.ibm.ws.threading.internal.Worker.executeWork(Worker.java:398)
    at com.ibm.ws.threading.internal.Worker.run(Worker.java:380)
    at java.lang.Thread.run(Thread.java:770)
</pre>

Can somebody help on this?


回答1:


There are restrictions on cookie names, including a selection of reserved names/tokens[1]. (No need to worry about the specific environment in this case.) =) You may not use any of the following names (this list may not be exhaustive):

  • comment
  • discard
  • domain
  • expires
  • max-age
  • path
  • secure
  • version

Also, since cookies are case-insensitive[2], "Path" will spark the same java.lang.IllegalArgumentException as "path" will.

As for the restrictions, cookie names:

  • must not be null or empty[3]
  • must not contain any whitespace[3]
  • must not start with $[2]
  • must not include commas , or semicolons ;[3]

=)

References

  1. "Cookie Reserved Names- Who's to blame?" article
  2. RFC 2109 specification (see sections 4.1 and 4.2.2 respectively)
  3. Java EE 6 Cookie constructor documentation



回答2:


From the stacktrace, it looks like that the cookie from the client side (maybe the browser ?) has an invalid name. Per the Cookie java doc, some reserved words are not allowed for cookie name.

java.lang.IllegalArgumentException - if the cookie name is null or empty or contains any illegal characters (for example, a comma, space, or semicolon) or matches a token reserved for use by the cookie protocol



来源:https://stackoverflow.com/questions/16608535/was-liberty-profile-java-lang-illegalargumentexception-cookie-name-path-is-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!