JavaOne Session Video

We are having such a great days here in JavaOne 2016 (San Francisco). Today was the day that we did our talk – “High Availability with Docker and JavaEE (Step by Step)” – and fortunately it was recorded! So I’ll give you the link in the case you wanna watch it.

I’ll give some impressions about some points of view, but probably will wait some more days to do it.

Enjoy and leave your comments!

Check the video here!

Using Docker to deal with a TomEE missing feature

When I and Bruno Souza were writing the article “Step-by-Step High Availability with Docker and Java EE” we faced a little issue with an Apache TomEE cluster feature: the “hot” deployment thru the cluster nodes isn’t still available, although the configuration at the server.xml is already defined:


The point is: if you deploy a new version of your application in one node, it doesn’t spread thru your entire cluster. At the first moment we look at this as some kind of a tricky situation that we must deal with.

But talking for just a few moments we realized that the article purpose itself was the answer for that issue! How? Simple…

When we create an appliance (for the definition, take a look at the article) we already have the application deployed to our application server. So when we use this appliance to build our cluster (running multiple Docker instances with properly configurations) we don’t need any other deployment at all!

Containers to the rescue! 😉

Dynamic and Static Discovery cluster with Apache TomEE

Hey there!

On my last post Are there different types of clusters? we saw two different types of clusters: Dynamic Discovery and Static Discovery. To see details, see the post! 😉

Now let’s see quickly how we can set them up at the Apache TomEE. One of the types – the Dynamic – we have already seen in the post How to build an Apache TomEE cluster. So we will do just a little zoom to see where the things are done.


Dynamic Discovery

At the “Engine” node you should put this code (see the post mentioned above for detailed code):



Static Discovery

At the same “Engine” node you should put this:

<Cluster className=”org.apache.catalina.ha.tcp.SimpleTcpCluster”channelSendOptions=”6″>
<Channel className=””>
<Interceptor className=””>
<Member className=”org.apache.catalina.tribes.membership.StaticMember” port=”4000″ host=”server1″ uniqueId=”{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}” />
<Member className=”org.apache.catalina.tribes.membership.StaticMember” port=”4000″ host=”server2″ uniqueId=”{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}” />
<Member className=”org.apache.catalina.tribes.membership.StaticMember” port=”4000″ host=”server3″ uniqueId=”{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3}” />


So as you can see, with the Static Discovery you use the StaticMember at the Member node instead of McastService used at the Dynamic Discovery. To see the functional differences between them see my last post Are there different types of clusters?.

Hope you enjoy building your own TomEE cluster! If you have any particular experience to share, please leave it at the comments bellow. See you!

How to build an Apache TomEE cluster

If you have an application or a system and it is running, you surely want it to be available. Depending on the scenario, you need it to be highly available! Or perhaps you just want to balance the loading on your server.

In any of those cases a good choice maybe is to build a cluster. Just to give you an overview and in the case this is a new word for you, cluster is a set of independent servers that communicate to each other thru a network in order to make a service or a system to be more available than if you used just one server.

Each server of the cluster is called a node. That are some different types of cluster, but we will cover it in another post.

If you are a Java developer and are familiar with Tomcat you will find TomEE quite easy to use. They have almost the same structure and are very likely to setup. The “plus” for TomEE is: it is Java EE (6) compatible for web profile.

What does it mean? Means that it implements all the Java EE 6 web API’s related. So if you are a Web Developer and wanna take advantage of Java EE 6 on your project, the Apache TomEE could be a good choice.

So you have an application, want to run it in a TomEE and want to do it in a cluster? Easy! Let’s do it step by step.

  • Download and install the JDK and the Apache TomEE. I’ll assume you are familiar with it. I am wrong, please leave a message at the comments bellow;
    • The versions used were: JDK 1.8.73 and Apache TomEE 1.7.3 Web Profile. The SO was a Mac OS X 10.11.3 (El Captain).
  • After installing try to run your TomEE and see if it is working;
  • Go to your TomEE Home folder and edit the following file:
    • /conf/server.xml
  • Add those lines to the “Engine” node:
mapSendOptions=”6″ />
dropTime=”3000″ />
maxThreads=”6″ />
className=”org.apache.catalina.tribes.transport.nio.PooledParallelSender” />
className=”” />
className=”” />
className=”” />
<Valve className=”org.apache.catalina.ha.tcp.ReplicationValve”
filter=”.*\.gif|.*\.js|.*\.jpeg|.*\.jpg|.*\.png|.*\.htm|.*\.html|.*\.css|.*\.txt” />
watchEnabled=”false” />
className=”org.apache.catalina.ha.session.ClusterSessionListener” />
  • Save and close your file, then restart your TomEE. If everything is ok, your log file should have something like this:
org.apache.catalina.ha.tcp.SimpleTcpCluster startInternal
Cluster is about to start
org.apache.catalina.tribes.transport.ReceiverBase bind
Receiver Server Socket bound to:/
org.apache.catalina.tribes.membership.McastServiceImpl setupSocket
Setting cluster mcast soTimeout to 500
org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
Sleeping for 1000 milliseconds to establish cluster membership, start level:4
org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
Done sleeping, membership established, start level:4
org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
Sleeping for 1000 milliseconds to establish cluster membership, start level:8
org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
Done sleeping, membership established, start level:8
  • Great! Now you have the first node of your cluster up and running. Not enough, right? So do it to another server, could be another machine or even a VM. Do it to as many servers as you want according to your needs. Each time you add a new node, the log file of other nodes should contain something like this: getBufferPool
Created a buffer pool with max size:104857600 bytes of
org.apache.catalina.ha.tcp.SimpleTcpCluster memberAdded
Replication member added:org.apache.catalina.tribes.membership.MemberImpl[tcp://{192, 168, 0, 107}:5000,{192, 168, 0, 107},5000, alive=1016, securePort=-1, UDP Port=-1, id={111 -38 59 -66 -68 -29 72 -69 -103 12 -121 -120 -13 -25 -90 17 }, payload={}, command={}, domain={}, ]
  • Now you have your beautiful cluster fully happy and working! There is just one thing missing: your application deployed to it. Simple:
    • Edit the web.xml of your application;
    • Add this attribute: <distributable />;
    • Save the file, close it and deploy to your cluster.

Couldn’t be easier, right? Of course there are some other aspects, some architectural gaps and another options, but I will leave it for your comments and for another posts.

See ya!