0 Replies Latest reply on Mar 10, 2016 4:12 AM by Maxwell Xiang

    Jboss cluster can not work with 2 instances run on one machine

    Maxwell Xiang Newbie



      I'm new to Jboss and EJB. I'm trying to form a Jboss cluster with 2 instances  and connect the cluster from tomcat, all the Jboss instances and tomcat run on one machine. The problem is the 2 instances of Jboss can form a cluster, but tomcat only connect only one node of the cluster, when I shudown the node that was connected by tomcat, the tomcat still try to connect it and can not try to connect the other node.So it always shows that connecting is refused.


      Below is the detail:

      1. About the environment                                                


         uses ------> apache(https port443)---->tomcat---|


         Apache is a loadbanlancer with AJP, tomcat work as EJB client to call Jboss. Jboss1 and Jboss2 run on different ports (I changed default ports one by one, ie jnp ports are 1199 and 1299,ha-jndi ports are 1200 and 1300)

         and formed a cluter with DefaultPartition. All the applications are good, cause they are copied from production system. And the tomcat can connect jboss1 and jboss2 sepratedly with

         the respective jndi url(standalone, not for cluster)


      2. Configurations

        A.Tomcat jndi configuration:





         B.Jboss configurations

         jboss cluster configuration:

         I just use the default configuration for cluster with DefaultPartition, jgroups work in default UDP stack .


         jndi configuration (no ports are defined):






         jboss.xml for EJB









      I add "<clustered>True</clustered>" for every section os session in jboss.xml of the EJB.



        jboss cluster:

      when I start the 2 instances of jboss, it shows in log like this:


        GMS: address is


      02:42:35,063 INFO  [DefaultPartition] Number of cluster members: 1

      02:42:35,063 INFO  [DefaultPartition] Other members: 0

      02:42:35,064 INFO  [DefaultPartition] Fetching state (will wait for 30000 milliseconds):

      02:42:35,064 INFO  [DefaultPartition] State could not be retrieved (we are the first member in group)

      02:42:35,143 INFO  [HANamingService] Started ha-jndi bootstrap jnpPort=1200, backlog=50, bindAddress=localhost/

      02:42:35,155 INFO  [DetachedHANamingService$AutomaticDiscovery] Listening on /, group=, HA-JNDI address=


      02:42:44,881 INFO  [DefaultPartition] New cluster view for partition DefaultPartition (id: 1, delta: 1) : [,]

      02:42:44,888 INFO  [DefaultPartition] I am ( received membershipChanged event:

      02:42:44,912 INFO  [DefaultPartition] Dead members: 0 ([])

      02:42:44,913 INFO  [DefaultPartition] New Members : 1 ([])

      02:42:44,914 INFO  [DefaultPartition] All Members : 2 ([,])




      GMS: address is


      02:42:44,932 INFO  [DefaultPartition] Number of cluster members: 2

      02:42:44,932 INFO  [DefaultPartition] Other members: 1

      02:42:44,933 INFO  [DefaultPartition] Fetching state (will wait for 30000 milliseconds):

      02:42:45,137 INFO  [DefaultPartition] state was retrieved successfully (in 204 milliseconds)

      02:42:45,278 INFO  [HANamingService] Started ha-jndi bootstrap jnpPort=1300, backlog=50, bindAddress=localhost/

      02:42:45,290 INFO  [DetachedHANamingService$AutomaticDiscovery] Listening on /, group=, HA-JNDI address=

      02:42:45,655 INFO  [TreeCache] No transaction manager lookup class has been defined. Transactions cannot be used

      02:42:45,804 INFO  [InterceptorChainFactory] interceptor chain is:

      class org.jboss.cache.interceptors.CallInterceptor

      class org.jboss.cache.interceptors.EvictionInterceptor

      class org.jboss.cache.interceptors.PessimisticLockInterceptor

      class org.jboss.cache.interceptors.PassivationInterceptor

      class org.jboss.cache.interceptors.ActivationInterceptor

      class org.jboss.cache.interceptors.UnlockInterceptor

      class org.jboss.cache.interceptors.ReplicationInterceptor

      class org.jboss.cache.interceptors.TxInterceptor

      class org.jboss.cache.interceptors.CacheMgmtInterceptor

      02:42:45,880 INFO  [STDOUT]



      when shutdown Jboss1:

      logs on Jboss2----(it can detect the dead of Jboss1)

      02:50:36,022 INFO  [JMSContainerInvoker] Waiting for reconnect internal 10000ms for NeonTaskControllerBean

      02:50:44,679 INFO  [TreeCache] viewAccepted(): [|2] []

      02:50:44,786 INFO  [TreeCache] viewAccepted(): [|2] []

      02:50:44,935 INFO  [DefaultPartition] New cluster view for partition DefaultPartition (id: 2, delta: -1) : []

      02:50:44,965 INFO  [DefaultPartition] I am ( received membershipChanged event:

      02:50:44,965 INFO  [DefaultPartition] Dead members: 1 ([])

      02:50:44,965 INFO  [DefaultPartition] New Members : 0 ([])

      02:50:44,965 INFO  [DefaultPartition] All Members : 1 ([])



      errors on tomcat:

      ExceptionHandler] URL=[], QueryString=[null], Referer=[], SessionId=[7F3DA2CC9AA76C66C091448DEB3EDD7E], orgCode=[testzfc], Exception type=[org.jboss.remoting.CannotConnectException], message=[Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket://localhost:5446/?clientMaxPoolSize=300&dataType=invocation&enableTcpNoDelay=true&marshaller=org.jboss.invocation.unified.marshall.InvocationMarshaller&socketTimeout=600000&unmarshaller=org.jboss.invocation.unified.marshall.InvocationUnMarshaller]]

      - org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket://localhost:5446/?clientMaxPoolSize=300&dataType=invocation&enableTcpNoDelay=true&marshaller=org.jboss.invocation.unified.marshall.InvocationMarshaller&socketTimeout=600000&unmarshaller=org.jboss.invocation.unified.marshall.InvocationUnMarshaller]


      the url "localhost:5446" in error log of tomcat is just the JNP port of Jboss1.


      What's sometimes when I started the 2 instances of Jboss, the tomcat connects Jboss2  instead, I do not know the rule. But the resule is the same, tomcat can only recongnize and connect one member of Jboss cluster, unless I restart the tomcat after shuting down the one instance of jboss that was connected successfully by the tomcat.



      Could someone tell me what's wrong with this? Thanks in advance!