[Please forward your answer to both this newsgroup and epr...@ubiquity.net. (I have limited newsgroup access now.) Thanks!]
I'm trying to set up a simple JMS client that maintains a JMS topic subscriber connected. On my first try I am successful; the JMS messages go through. I registered an ExceptionListener and when the connection is lost (WLS crashes) I want to try again in 30 seconds. I destroy (close() and =null) all my objects.
When WLS starts again, the client is trying to reconnect. At this point I get a LostServerException in onException() and later in my timer's run() method when I try to recreate the subscriber I get a IllegalStateException: Connection is closed. These two exceptions are shown below.
I think this may be a bug in WLS 8.1 JMS client classes. Somehow WLS client classes are trying to keep the connection open to the server, and fail to reconnect on the second time. How do I get around this problem?
Yours,
Emmanuel
weblogic.jms.common.LostServerException: weblogic.rmi.extensions.server.HeartbeatMonitorException: HeartbeatMonitor fails; nested exception is:
java.rmi.NoSuchObjectException: CORBA OBJECT_NOT_EXIST 1330446337 No; nested exception is:
org.omg.CORBA.OBJECT_NOT_EXIST: vmcid: OMG minor code: 1 completed:
No
at weblogic.jms.client.JMSConnection.jmsPeerGone(JMSConnection.java:907)
at weblogic.jms.dispatcher.DispatcherWrapperState.peerGone(DispatcherWra
pperState.java:708)
at weblogic.jms.dispatcher.DispatcherWrapperState.callback(DispatcherWra
pperState.java:568)
at weblogic.rmi.extensions.server.AbstractHeartbeatMonitorDelegate.deliv
erHeartbeatMonitorListenerException(AbstractHeartbeatMonitorDelegate.java:152)
at weblogic.rmi.extensions.server.AbstractHeartbeatMonitorDelegate.acces
s$500(AbstractHeartbeatMonitorDelegate.java:32)
at weblogic.rmi.extensions.server.AbstractHeartbeatMonitorDelegate$Pinge
r.run(AbstractHeartbeatMonitorDelegate.java:277)
at java.lang.Thread.run(Thread.java:534)
weblogic.jms.common.IllegalStateException: Connection is closed
at weblogic.jms.client.JMSConnection.getFrontEndDispatcher(JMSConnection.java:426)
at weblogic.jms.client.JMSSession.consumerCreate(JMSSession.java:1860)
at weblogic.jms.client.JMSSession.createConsumer(JMSSession.java:1691)on
at weblogic.jms.client.JMSSession.createSubscriber(JMSSession.java:1409)
at com.onstar.asd.sipserver.MessageSender$1.run(MessageSender.java:275)
at java.util.TimerThread.mainLoop(Timer.java:432)
at java.util.TimerThread.run(Timer.java:382)
Emmanuel
Anyhow, if you like, post your sample code and WL version, and I'll take a quick look...
Tom
I think the JMS client classes are keeping stuff in memory (not GC'd), even if I set everything to null. The reason I think that is - my application is a kind of servlet which I can't undeploy cleanly it seems.
---
private Hashtable connections = new Hashtable();
public void setListener(String topicName, MessageListener listener)
throws JMSException, NamingException {
Connection connection = new Connection();
connection.setListener(topicName, listener);
connections.put(topicName, connection);
}
public void unsetListener(String topicName) throws JMSException {
Connection connection = (Connection) connections.get(topicName);
if(connection==null)
return;
connection.unsetListener();
connections.remove(topicName);
}
private class Connection implements ExceptionListener {
TopicConnection connection;
TopicSubscriber subscriber;
String topicName;
TopicSession topicSession;
Timer timer = null;
boolean connected = false;
public void onException(JMSException error) {
log.error(
"Error coming from the JMS stack. Retrying in 30 seconds.",
error);
disconnect();
}
private void disconnect() {
connected = false;
try {
subscriber.close();
} catch (JMSException e1) {
//Do nothing!
}
subscriber=null;
try {
topicSession.close();
} catch (JMSException e) {
//Do nothing!
}
topicSession=null;
try {
connection.setExceptionListener(null);
connection.close();
} catch (JMSException e2) {
//Do nothing!
}
connection=null;
}
public void unsetListener() {
if (timer != null) {
try {
timer.cancel();
timer = null;
disconnect();
log.debug("JMS Listener unregistered! " + topicName);
} catch (Throwable e) {
log.error("Error unsetting the listener in unsetListener().",
e);
}
}
log.debug("JMS listener unset! ");
}
public void setListener(final String topicName,
final MessageListener listener) {
//Here the JMS connection is gone. Re-schedule a new connection in 30 seconds
if (timer != null) {
try {
timer.cancel();
timer = null;
} catch (Throwable e) {
log.error("Error unsetting the timer in setListener().", e);
}
}
this.topicName = topicName;
final Connection parent = this;
timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
if(log.isDebugEnabled())
log.debug("Checking if the JMS connection is still alive..." + topicName);
if (connected == true)
return;
log.debug("Connection dead! Retrying.");
try {
ConfigProperties msgProperties = ConfigProperties
.getInstance();
Context jndiContext = getContext();
TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory) jndiContext
.lookup(msgProperties
.getProperty("jmsConnectionFactory"));
connection = topicConnectionFactory
.createTopicConnection();
connection.setExceptionListener(parent);
connection.start();
topicSession = connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
Topic topic = (Topic) jndiContext.lookup(topicName);
subscriber = topicSession.createSubscriber(topic); //***
subscriber.setMessageListener(listener);
log.debug("JMS Listener registered! " + topicName);
connected = true;
} catch (Throwable e) {
log.error("Error while connecting to JMS.", e);
}
}
},
0, //start now...
30000); //retry every 30 seconds.
}
}
http://forums.bea.com/bea/message.jspa?messageID=202434401
Apparently this issue goes away when using weblogic.jar instead of wlclient.jar and wljmsclient.jar. Also BEA is working on a fix.
Emmanuel