Session Replication Error in clustered environment


Web tier: servlets, JSP, Web frameworks: Session Replication Error in clustered environment

  1. In my servlet,I have an object(QUEUERECEIVER) I am storing it in the
    HttpSession using getSession().setAttribute. The object is an instance
    of QueueReceive class ( code attached below).I have also turned on the
    session replication using PersistentStoreType in weblogic.xml.
    Since this is running in a clustered environment with multiple
    servers, the submitted request can go to a different server and it
    will try to do a getAttribute for the QUEUERECEIVER object.

    The session replication is failing with the exception below. Does
    anyone has any ideas to this problem. Please let me know if more
    details are required.
    I am using weblogic 7.0

    Raja weblogic.jms.client.JMSConsumer
            at java.util.Hashtable.writeObject(
            at java.lang.reflect.Method.invoke(Native Method)

    --------------------------------X Code of
    import java.util.*;
    import javax.transaction.*;
    import javax.naming.*;
    import javax.jms.*;

    public class QueueReceive
        implements MessageListener,Serializable {
       * Defines the JNDI context factory.
      public final static String JNDI_FACTORY =

       * Defines the JMS connection factory for the queue.
      public final static String JMS_FACTORY = "";

       * Defines the queue.
      public final static String QUEUE = "md_receiver_queue";

      private QueueConnectionFactory qconFactory;
      private QueueConnection qcon;
      private QueueSession qsession;
      private QueueReceiver qreceiver;
      private Queue queue;
      private boolean quit = false;

      private boolean done = false;
      private String correlationId = "";
      private boolean background = false;
      private String responseMessage = null;

       * Message listener interface.
       * @param msg message

      public synchronized boolean isDone() {
        return done;

      public synchronized void setBackground() {
        background = true;

      public synchronized boolean isBackground() {
        return background;

      public synchronized String getResponseStr() {
        return responseMessage;

      // MessageListener interface
      public void onMessage(Message msg) {
        try {
          String msgText;
          if (msg instanceof TextMessage) {
            msgText = ( (TextMessage) msg).getText();
          else {
            msgText = msg.toString();
          this.responseMessage = msgText;

          synchronized (this) {
            done = true;
            if (background == true) {
              System.out.println("Redirecting to background queue");
            else {
    // this.close();
        catch (JMSException jmse) {
        finally {
       * @param ctx Context
       * @param queueName String
       * @throws NamingException
       * @throws JMSException
      public void init(Context ctx, String queueName) throws
          JMSException {
        qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
        qcon = qconFactory.createQueueConnection();
        qsession = qcon.createQueueSession(true, -1);
        queue = (Queue) ctx.lookup(queueName);
        String selector = "JMSCorrelationID = '" + correlationId + "'";
        qreceiver = qsession.createReceiver(queue, selector);

       * Closes JMS objects.
       * @exception JMSException if JMS fails to close objects due to
    internal error
      public void close() throws JMSException {
      public QueueReceive(String correlationId)

        try {
          this.correlationId = correlationId;
          InitialContext ic = getInitialContext("t3://yukon-dev:7003");
          this.init(ic, QUEUE);
        catch (javax.naming.NamingException ne) {
          System.out.println("Naming exception occured");
        catch (javax.jms.JMSException je) {
          System.out.println("JMS exception occured");

      private static InitialContext getInitialContext(String url) throws
          NamingException {
        Hashtable env = new Hashtable();
        env.put(Context.PROVIDER_URL, url);
        env.put(Context.SECURITY_PRINCIPAL, "system");
        env.put(Context.SECURITY_CREDENTIALS, "********");

        return new InitialContext(env);


    Threaded Messages (2)

  2. Implement[ Go to top ]

    You need to implement in your object. That is the java interface for reading and writing the state of an object. Otherwise, java does not know how to transport your class from one JVM to the next.

    You wrote:
    The session replication is failing with the exception below.

    Doesanyone has any ideas to this problem. Please let me know if moredetails are required.I am using weblogic 7.0
  3. Oops.[ Go to top ]

    Sorry. I see that you are.....

    Are you sure that all of the contained objects of your class are also implementing Serializable? You might want to check that, because if one of them has a member variable that is not serializable, it will not work.