There's more...

A common issue for this clustering with GlassFish arises when you don't have the SSH service running in your nodes; as there are tons of options of them for many operating systems, we won't cover each one of them here.

The best way to set up a Java EE cluster today is using containers (specially Docker containers). So, I'd recommend that you have a look at Chapter 11, Rising to the Cloud – Java EE, Containers, and Cloud Computing. If you mix that content with this, you will have a powerful environment for your application.

To allow your application to share its session with all the nodes in the cluster, you need to edit the web.xml file, find the web-app node, and insert this:

<distributable/>

Without it, your session clustering ...

Get Java EE 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.