Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session issue in Wildfly 10.1.0

I have two web appplications 1. test.war 2. birt.war

I set cookies in http response header for birt url

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

Then I open birt url with appropriate url parameters in javascript like

window.open(url);

But the next request from birt I get have new JSESSIONID. This works in JBoss6 AS.

I am able to see the cookies in developer console

**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

Also I tried adding in both wars in jboss-all.xml but even that does not work.

<shared-session-config xmlns="urn:jboss:shared-session-config:1.0">
        <session-config>
            <cookie-config>
                <path>/</path>
            </cookie-config>
        </session-config>
</shared-session-config>
like image 998
happy Avatar asked Sep 27 '17 12:09

happy


2 Answers

I believe that your deployment model is different from the one Undertow supports:

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

Please referece https://docs.jboss.org/author/display/WFLY10/Web+(Undertow)+Reference+Guide

like image 131
Aleh Maksimovich Avatar answered Nov 17 '22 22:11

Aleh Maksimovich


Here we share the same session between wars in Wildfly 10.1 by configuring single-sign-on property in the undertow subsystem (domain.xml / standalone.xml). Like this:

<subsystem xmlns="urn:jboss:domain:undertow:3.1">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener max-post-size="1073741824" name="default" socket-binding="http"/>

        <host alias="localhost" name="default-host">
            <single-sign-on path="/"/>
        </host>
    </server>
    .
    .
    .
</subsystem>

And in jboss-web.xml, inside the war files, we set the disable-cross-context property to false:

<jboss-web>
    <context-root>/test</context-root>
    <disable-cross-context>false</disable-cross-context>
    .
    .
    .
</jboss-web>

If this doesn't work, please provide your war files.

like image 25
Alessandro Hoss Avatar answered Nov 17 '22 22:11

Alessandro Hoss