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

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

    linuxlogic

      Hi,

       

      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                                                

                                                                             |------Jboss1

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

                                                                             |------Jboss2

         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:

         java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

         java.naming.provider.url=localhost:1200,localhost:1300

         java.naming.factory.url.pkgs=org.jboss.naming

        

         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):

         # DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING

         #

         java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory

         java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

        

         jboss.xml for EJB

         <jboss>

          <enterprise-beans>

             <session>

                <ejb-name>DBNFacade</ejb-name>

                <jndi-name>dbn/DBNFacadeBean</jndi-name>

                <clustered>True</clustered>

             </session>

       

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

       

      3.Logs

        jboss cluster:

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

        Jboss1:

        GMS: address is 127.0.0.1:58279

      -------------------------------------------------------

      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/127.0.0.1

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

       

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

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

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

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

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

        

        Jboss2:

      -------------------------------------------------------

      GMS: address is 127.0.0.1:39298

      -------------------------------------------------------

      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/127.0.0.1

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

      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(): [127.0.0.1:48325|2] [127.0.0.1:54530]

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

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

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

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

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

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

       

       

      errors on tomcat:

      ExceptionHandler] URL=[https://192.168.1.232/np/security/signIn.do], QueryString=[null], Referer=[https://192.168.1.232/np/clients/testzfc/login.jsp], 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!