1

I have two application that run in two Glassfish Instances, i configure my apache to use sticky session like so :

ProxyPass / balancer://Appcluster/ stickysession=JSESSIONID

But this not work 100% correct, it change some times the instance when the client goes from App1 to App2.

I check the cookies in my navigator it show me something like this :

cookies of browser

I found another configuration in web.xml, like so :

<session-config>
    <session-timeout>
        30
    </session-timeout>
    <cookie-config>
        <path>/</path>
    </cookie-config>
</session-config>

So when i make this path like this every thing work fine, but it create a new context every navigation between this two application.

Now i configure my Glassfish and set the App1 like a Default Web Module, this work fine and the context is the same, and the sever create a new cookie like this :

cookies of browser

But when i try to connect with the NO Default Web Module, it use two Instances.

Can you please propose the right configuration of Apache and Glassfish to run multiple application in a cluster environment?

EDIT

I notified some thing, so when client goes from App1 to App2, and the VS, every time it create a new cookie like this:

+-------+----------------------------------------+
| APP   | Cookie                                 |
+-------+----------------------------------------+-----+
| app1  | b5a1cd4befdc306f6e569d835b5e.instance2 | New |              
+-------+----------------------------------------+-----+
| app2  | b6caf890638a506216d625f7c82b.instance2 | New |                                  
+-------+----------------------------------------+-----+
| app1  | b6d1870ad8f3d044cc768b31e810.instance2 | New |                                   
+-------+----------------------------------------+-----+
| app2  | b6d84bf7b2a6fc37e3c9ffaf701b.instance2 | New |
+-------+----------------------------------------+-----+
| app2  | b6d84bf7b2a6fc37e3c9ffaf701b.instance2 |Same | because i don't change the application
+-------+----------------------------------------+-----+    
  • Why this create a new cookie every time?
  • How can fix and make it unique per application?

1 Answers1

0

After one week of search finally i found the solution :

I use two things, one in the two applications and one in the server Apache :

So in the applicatons we should to define the name of the cookie in web.xml:

APP1

<session-config>
    <session-timeout>
        30
    </session-timeout>

    <cookie-config>
        <name>jsessionapp1</name>
        <path>/</path>
    </cookie-config>
</session-config>

APP2

<session-config>
    <session-timeout>
        30
    </session-timeout>

    <cookie-config>
        <name>jsessionapp2</name>
        <path>/</path>
    </cookie-config>
</session-config> 

And in the server Apache we fix the name of stickysession in /etc/httpd/conf/httpd_proxy.conf :

ProxyPass / balancer://Appcluster/ stickysession=jsessionapp1|jsessionapp2|jsessionappN

I don't know if there another solutions better than this, if yes i will be happy to know them.