Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Session Replication Error in clustered environment ( Tom please answer this )

1 view
Skip to first unread message

Raja

unread,
Apr 8, 2004, 3:00:20 PM4/8/04
to
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

Thanks
Raja

java.io.NotSerializableException: weblogic.jms.client.JMSConsumer
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1143)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1822)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:475)
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1209)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1822)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:475)
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1209)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
at java.util.Hashtable.writeObject(Hashtable.java:759)
at java.lang.reflect.Method.invoke(Native Method)


--------------------------------X Code of QueueReceive.java
X-------------------
import java.io.*;
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 =
"weblogic.jndi.WLInitialContextFactory";

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

/**
* 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) {
qsession.rollback();
System.out.println("Redirecting to background queue");
}
else {
qsession.commit();
}
}
// this.close();
}
catch (JMSException jmse) {
jmse.printStackTrace();
}
finally {
}
}
/**
*
* @param ctx Context
* @param queueName String
* @throws NamingException
* @throws JMSException
*/
public void init(Context ctx, String queueName) throws
NamingException,
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);
qreceiver.setMessageListener(this);
qcon.start();
}

/**
* Closes JMS objects.
* @exception JMSException if JMS fails to close objects due to
internal error
*/
public void close() throws JMSException {
qreceiver.close();
qsession.close();
qcon.close();
}
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");
ne.printStackTrace();
}
catch (javax.jms.JMSException je) {
System.out.println("JMS exception occured");
je.printStackTrace();
}
}


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

return new InitialContext(env);
}


}

0 new messages