- I try here to close the XAConnection and XASession
session.close()
connection .close()
- but the server shows me this Exception:

2008-07-18 09:30:14,093 DEBUG [org.jboss.mq.il.uil2.ServerSocketManagerHandler] Exiting on IOE
java.net.SocketException: Socket closed
at java.net.SocketInputStream.read(SocketInputStream.java:162)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
at org.jboss.util.stream.NotifyingBufferedInputStream.read(NotifyingBufferedInputStream.java:79)
at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2196)
at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2376)
at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2443)
at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2515)
at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2664)
at java.io.ObjectInputStream.readByte(ObjectInputStream.java:875)
at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:316)
at java.lang.Thread.run(Thread.java:595)
2008-07-18 09:30:14,094 DEBUG [org.jboss.mq.il.uil2.SocketManager] End ReadTask.run
2008-07-18 09:30:14,092 DEBUG [org.jboss.mq.il.uil2.SocketManager] End WriteTask.run
2008-07-18 09:30:14,094 DEBUG [org.jboss.mq.il.uil2.SocketManager] End ReadTask.run
2008-07-18 09:30:14,092 DEBUG [org.jboss.mq.il.uil2.SocketManager] Failed to handle: org.jboss.mq.il.uil2.msgs.CloseMsg33151655[msgType: m_connectionClosing,
msgID: -2147446000, error: null]
java.io.IOException: Client is not connected
at org.jboss.mq.il.uil2.SocketManager.internalSendMessage(SocketManager.java:264)
at org.jboss.mq.il.uil2.SocketManager.sendReply(SocketManager.java:238)
at org.jboss.mq.il.uil2.ServerSocketManagerHandler.handleMsg(ServerSocketManagerHandler.java:131)
at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleMsg(SocketManager.java:395)
at org.jboss.mq.il.uil2.msgs.BaseMsg.run(BaseMsg.java:398)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
at java.lang.Thread.run(Thread.java:595)
2008-07-18 09:30:14,095 DEBUG [org.jboss.mq.il.uil2.SocketManager] Failed to send error reply
java.io.IOException: Client is not connected
at org.jboss.mq.il.uil2.SocketManager.internalSendMessage(SocketManager.java:264)
at org.jboss.mq.il.uil2.SocketManager.access$800(SocketManager.java:53)
at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleMsg(SocketManager.java:408)
at org.jboss.mq.il.uil2.msgs.BaseMsg.run(BaseMsg.java:398)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
at java.lang.Thread.run(Thread.java:595)

Does any one know why ? And what should I do to close the session and the connection correctly?

Did you use finally block in catch clause to finish the operation? Something like this?

try {
    // some data processing
    }
}
catch (XAException e) {
    e.printStackTrace();
}
finally {
    stmt.close();
    con.close();
    xaCon.close();
}

If you have in above manner then please post your code so we can have look at it

Hello,
I am using EJB, so I build a connecion using:

@PostConstruct
public void postConstructCallback() {
try {
XAConnectionFactory factory = (XAConnectionFactory) ctx.lookup("XAConnectionFactory");
cnn = factory.createXAConnection();
session = cnn.createXASession();
connection.start();
} catch (JMSException e) {
}

and close it using:

@PreDestroy
public void myDestroy() {
session.close()
connection .close()
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.