0 Replies Latest reply on Aug 12, 2005 9:47 AM by v v

    Statefull session bean Cluster problem in 4.0.2

    v v Newbie

      Hello All,


      I have encountered the clustering problem while testing my clustered application in Jboss-4.0.2 server.I have created a stateful session bean called CountBean with clustered configuration as specified in Jboss cluster document.My CountBean maintains the count values.I have deployed the servlet (.war) file in one machine say machine 1 and CounterEJB(.jar) file in two machines say machine1,machine2.

      I have tested my application with following two scenarios

      Scenario1 :
      --------------------------------------->machine1( CounterEJB session bean)
      --------- ----> same object. |
      servlet ----> ---------------->|
      --------- ----> ---------------- |
      --------------------------------- ------>machine2( CounterEJB session bean)


      From the servlet I have created Bean object using home.create() with HAJNDI lookup method, assumes that the request goes to machine1. While accessing the Counter Bean using the same object reference it maintains the count value state for each call. When I remove the CounterEJB in machine1, the request is not forwared to machine2 and throws Null object reference exception.


      Scenario2:

      --------------------------------------->machine1( CounterEJB session bean)
      --------- ----> diff.. object. |
      servlet ----> ---------------->|
      --------- ----> ---------------- |
      --------------------------------- ------>machine2( CounterEJB session bean)


      When we invoke the Counter Bean method each time, we create a new session object using home.create(), which returns a different object .
      For each call the CounterBean does not maintain the state. If we remove the CounterEJB in machine1, the request is forwared to machine2.


      On the following two scenarios i couldn't get the expected result that is on scenario 1 Session object is not passed and on the scenario 2 not able to maintains it's state.


      The snippet of my clustered Jndi look up, ejb-jar.xml and Jndi.properties are given below


      <!------------------------------ Snippet of Servlet file --------------------------------------------->

      ctx = new InitialContext();
      Properties properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      properties.setProperty(Context.PROVIDER_URL, "jnp://localhost:1100");
      Object obj = new InitialContext(properties).lookup("Count");


      <!------------------------------ Snippet of ejb-jar.xml file --------------------------------------------->

      True
      <cluster-config>
      <partition-name>DefaultPartition</partition-name>
      <home-load-balance-policy>
      org.jboss.ha.framework.interfaces.RoundRobin
      </home-load-balance-policy>
      <bean-load-balance-policy>
      org.jboss.ha.framework.interfaces.FirstAvailable
      </bean-load-balance-policy>
      <session-state-manager-jndi-name>/HASessionState/Default
      </session-state-manager-jndi-name>


      my .war file contains the following jndi.properties file


      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      java.naming.provider.url=machine1:1100,machine2:1100

      Anything else i have to configure? Can anyone please explain why HAJNDI lookup is not properly working.

      Thanks,
      Kalimuthu.