Multiple Vaadin instances using multiple Jetty servers at the same time

I have a problem with multiple Vaadin instances, using 6.8.9 on some and on other 7.0.1. There are several legacy Java applications, to each of which I added a Vaadin frontend using an embedded Jetty instance, each with their own HTTP port. So let’s say I have three JVM instances, each with a Java application running a Jetty server on a different port with it’s own Vaadin application. Like this:
JVM1: FooJavaApp, Jetty on 8080, Vaadin 6.8.9, context “fooVaadin”
JVM2: BarJavaApp, Jetty on 8081, Vaadin 7.0.1, context “barVaadin”
JVM3: YAJavaApp, Jetty on 8082, Vaadin 7.0.1, context “yaVaadin”

Each of the Vaadin frontends runs totally fine by itself. But once I try to open one of the other Vaadin frontends in the same browser in another tab/different browser Window, the session in the previous Vaadin frontend closes immediately. I used Firefox for testing.

So why is the session closing on its own? It’s not a timeout, that value is set to 30 minutes and the closing happens immediately when I open one of the other frontends. Does it have something to do with the context configuration? Or cookies? What can I do about it?

I was able to identify the problem. It actually had nothing to do with Vaadin itself but with the Jetty context I set up in the web.xml file. As I wanted each web application to be available without any subpath, the cookies for each web application pointed to the same path with the same host. It seems that cookies don’t contain any port information, which I was not aware of. So each web application tried to access the same cookie. There are two ways to solve this:

  1. Change the URL path of each webapp to be an actual subpath, so for instance instead of “/”, let the subpath be “/foo/”.
  2. Change the name of the session cookie for each web application. This can be done in the form of context parameters in the web.xml file, by adding this:
<context-param>
    <param-name>org.eclipse.jetty.servlet.SessionCookie</param-name>
    <param-value>XSESSIONID</param-value>
  </context-param>
  <context-param>
    <param-name>org.eclipse.jetty.servlet.SessionIdPathParameterName</param-name>
    <param-value>xsessionid</param-value>
  </context-param>

I found the information on this website:
http://wiki.eclipse.org/Jetty/Howto/SessionIds

So not really that much Vaadin-related, but maybe someone else can find this information useful. :slight_smile:

You’ve saved my time! Thank you!
I’ve been making a deployment of my application to a cluster with two node instances on the same machine that use different HTTP ports. When I try to log in with the second instance the UI closes on all opened browser tabs. I had the idea that cluster has some problem with the session replication, but the answer is more simple: cookie does not have a port.