This content has been marked as final.
Show 3 replies
-
1. Re: java.util.ConcurrentModificationException appearing when
jaikiran Jan 14, 2009 7:52 AM (in response to croy)Please post the entire exception stacktrace. Do you always see this exception or is this intermittent?
While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted. -
2. Re: java.util.ConcurrentModificationException appearing when
croy Jan 14, 2009 8:51 AM (in response to croy)"jaikiran" wrote:
Please post the entire exception stacktrace. Do you always see this exception or is this intermittent?
While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.
Well the thread of execution never enters the catch block to print the stack trace so I never see one.
Yes, the problem was intermittent.
I have changed the code to include some logging in between the resource close statements and now the exception is not appearing in the server logs. Is it possible that some resource's internal reference counter is using a datasource that is not thread safe ? i.e. In the changed code below the very fact that I issue a log statement in between resource closing may be enough to remove the underlying resource contention ?public final static void sendMessageToQueue(String queueName, String amessage){ try{ QueueSession session=null; Queue que=null; QueueConnection conn=null; InitialContext iniCtx = new InitialContext(); Object tmp = iniCtx.lookup("ConnectionFactory"); QueueConnectionFactory qcf = (QueueConnectionFactory) tmp; conn = qcf.createQueueConnection(); que = (Queue) iniCtx.lookup(queueName); session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); QueueSender send = session.createSender(que); TextMessage tm = session.createTextMessage(amessage); send.send(tm); log.info("sendMessage, sent text=" + tm.getText() + " sent queue=" + queueName); if(send!=null){ send.close(); } log.debug("1"); if(conn!=null){conn.close();} log.debug("2"); if(session!=null){session.close();} log.debug("3"); }catch (Exception e){ log.error("In sendMessageToQueue: caught exception: " + e); // Path of execution never enters here e.printStackTrace(); } log.debug("DONE."); }
Log output is now always showing :2009-01-14 13:45:14,127 INFO [....utils.QueueUtil] (http-0.0.0.0-8080-23) sendMessage, sent text=1315712,N sent queue=queue/bidsQueue 2009-01-14 13:45:14,127 DEBUG [....utils.QueueUtil] (http-0.0.0.0-8080-23) 1 2009-01-14 13:45:14,128 DEBUG [....utils.QueueUtil] (http-0.0.0.0-8080-23) 2 2009-01-14 13:45:14,128 DEBUG [...utils.QueueUtil] (http-0.0.0.0-8080-23) 3 2009-01-14 13:45:14,128 DEBUG [....utils.QueueUtil] (http-0.0.0.0-8080-23) DONE.
-
3. Re: java.util.ConcurrentModificationException appearing when
jaikiran Jan 15, 2009 3:00 AM (in response to croy)Well the thread of execution never enters the catch block to print the stack trace so I never see one.
Not sure why it isn't entering the catch block, but its definitely your application's piece of code which is logging this message:2009-01-14 10:08:39,540 ERROR [....utils.QueueUtil] (http-0.0.0.0-8080-15) java.util.ConcurrentModificationException
which means that the control is definitely reaching the QueueUtil from where it is getting logged. Either that or some class in your application is using an incorrect Logger which is making the log message appear as being logged from QueueUtil