[jboss-user] [EJB3] - Configuring Applications For Both Clustered And Non Clustered Environments

Administrator Administrator do-not-reply at jboss.com
Thu Jan 20 11:00:39 EST 2011

Administrator Administrator [http://community.jboss.org/people/admin] modified the document:

"Configuring Applications For Both Clustered And Non Clustered Environments"

To view the document, visit: http://community.jboss.org/docs/DOC-13208

The aim of this wiki is to explain how to configure applications so that they can be deployed both as clustered and as non-clustered applications in the most efficient way.

h1. Do I Really Need To Do This?
It's worth noting that often, one of the reasons to deploy a clustered application in a non-clustered environment is for development purpouses. Maintaining a network where different developers are creating their clusters can be quite tricky from a multicast traffic management perspective but there're workarounds available to disable multicast traffic from landing on the network. Tricks like  http://community.jboss.org/docs/DOC-10211 setting up clustering via localhost or setting clustering traffic ttl to 0 via -Djgroups.udp.ip_ttl=0, constrain multicast traffic to the local machine, hence allowing developers to run their own clusters locally without affecting others. If you feel you still need to configure your application for both clustered and non-clustered environments, please read ahead.

h1. EJB2 or EJB3 Deployments
The easiest way to get EJBs deployed in as clustered in clustered environments and as non-clustered in non-clustered environments, is to define the clustering aspect via META-INF/jboss.xml rather than using @Clustered annotation in the case of EJB3s. JBoss has the capability of substituting pieces of XML with a specific value defined as a system property. So, for example, the following META-INF/jboss.xml allows you to control whether EJBs are deployed as clustered or not depending on whether -Dmyapp.is.clustered is defined or not. If -Dmyapp.is.clustered=true is passed when the server is started up, TimeTellerEjb will be deployed as clustered. If -Dmyapp.is.clustered=false is passed or no system property is defined on startup, the EJB will be deployed as non-clustered:
<?xml version="1.0"?>
<!DOCTYPE jboss PUBLIC -//JBoss//DTD JBOSS 4.0//EN

Unfortunately, there's currently no way of defining globally whether EJBs should be deployed as clustered or non-clustered.

h1. Web Deployments
In the of case WAR deployments, the way a web application is marked as clustered is by setting <distributable/> XML configuration element in WEB-INF/web.xml. Unfortunately, <distributable/> is an empty element and hence the same trick used with EJBs cannot be used. However, there's no problem in deploying a web application marked as <distributable/> in a non-clustered environment. Worst case scenario you'll get a WARN message like this during deployment but the application will work fine:
16:32:58,567 WARN  [TomcatDeployer] Failed to setup clustering, clustering disabled. NoClassDefFoundError: org/jgroups/blocks/MethodCall

Comment by going to Community

Create a new document in EJB3 at Community
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110120/f85a930d/attachment.html 

More information about the jboss-user mailing list