If it works on the same machine, your code is fine. Very likely the problem is with discovery - nodes do not find each other.
Look at your configured stack and check what discovery protocol you are using. If you are using TCPPING (http://www.jgroups.org/javadoc/org/jgroups/protocols/TCPPING.html) you need to reconfigure the IP addresses of the nodes.
Most likely, it will be MPING (http://www.jgroups.org/javadoc/org/jgroups/protocols/MPING.html) which uses multicast to discover nodes. Make sure multicast messages are being sent inbetween these nodes. Typically, firewalls drop this multicast communication (you can temporarily turn off firewall to test).
Also, check that your network components are not dropping multicast communication.