java – Wildfly 10.1.0中的会话问题

我有两个网络应用程序
test.war
birt.war

我在birt url的http响应头中设置了cookie

Cookie cookie = new Cookie(GlobalConstants.JSESSIONID, request.getSession(false).getId());
cookie.setPath("/birt");
response.addCookie(cookie);

然后我在javascript中用适当的url参数打开birt url

window.open(url);

但是来自birt的下一个请求我得到了新的JSESSIONID.这适用于JBoss6 AS.

我能够在开发者控制台中看到cookie

**Request 1**
http://192.168.10.7:8080/test

Cookies are 
Response Cookie :
JSESSIONID : 
value = 9G6bzvsF-ijbynGTmbWp7Ml4E5KFVHiEPlSflh16
Path = /birt

**Request 2**

http://192.168.10.7:8080/birt

Cookies are 
Response Cookie :
JSESSIONID : 
value = **xrLqLb5-8Vvqlkk2GKyapqwJZm5dJnyvFQOia9IM.node1** // new cookie
Path = /birt

Request Cookie :
JSESSIONID : 
value = 9G6bzvsF-ijbynGTmbWp7Ml4E5KFVHiEPlSflh16
Path = /birt

我也尝试在jboss-all.xml中添加两个战争,但即使这样也行不通.

<shared-session-config xmlns="urn:jboss:shared-session-config:1.0">
        <session-config>
            <cookie-config>
                <path>/</path>
            </cookie-config>
        </session-config>
</shared-session-config>

解决方法:

我相信您的部署模型与Undertow支持的部署模型不同:

Undertow allows you to share sessions between wars in an ear, if it is explicitly configured to do so. Note that if you use this feature your applications may not be portable, as this is not a standard servlet feature.

In order to enable this you must include a shared-session-config element in the jboss-all.xml file in the META-INF directory of the ear

请参考https://docs.jboss.org/author/display/WFLY10/Web+(Undertow)+Reference+Guide

上一篇:Keycloak Java适配器 – 检索列表角色


下一篇:java – Jboss上的Logback在记录时复制前缀和新行