views:

764

answers:

3

We have a web application deployed to Websphere 6.1.0.19 on Windows. We occasionally see this ConcurrentModificationException on a few of our reports. We are using JasperReports 2.0.5 in production. The full stacktrace is following:

java.util.ConcurrentModificationException
      at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:464)
      at java.util.AbstractList$Itr.next(AbstractList.java:435)
      at net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.next(JRBeanCollectionDataSource.java:91)
      at com.advtechgrp.bop.medical.reports.core.implementation.MedicalReportDataSourceImpl.next(MedicalReportDataSourceImpl.java:61)
      at net.sf.jasperreports.engine.fill.JRFillDataset.advanceDataSource(JRFillDataset.java:830)
      at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:748)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1438)
      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:111)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:895)      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:817)
      at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
      at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
      at com.advtechgrp.bop.medical.reports.core.MedicalReportBase.getReportList(MedicalReportBase.java:160)
      at com.advtechgrp.bop.medical.reports.core.implementation.MedicalReportCreator.createJasperExporter(MedicalReportCreator.java:275)
      at com.advtechgrp.bop.medical.reports.core.implementation.MedicalReportCreator.createExporter(MedicalReportCreator.java:228)
      at com.advtechgrp.bop.medical.reports.core.implementation.MedicalReportCreator.createReportUnsafe(MedicalReportCreator.java:196)
      at com.advtechgrp.bop.medical.reports.core.implementation.MedicalReportCreator.createReport(MedicalReportCreator.java:80)
      at com.advtechgrp.bop.medical.reports.core.web.MedicalReportServlet.doPost(MedicalReportServlet.java:132)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      at com.ibm.ws.cache.servlet.ServletWrapper.serviceProxied(ServletWrapper.java:282)
      at com.ibm.ws.cache.servlet.CacheHook.handleFragment(CacheHook.java:459)
      at com.ibm.ws.cache.servlet.CacheHook.handleServlet(CacheHook.java:265)
      at com.ibm.ws.cache.servlet.ServletWrapper.service(ServletWrapper.java:262)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1075)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1016)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:118)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:771)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:679)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:546)
      at com.ibm.ws.wswebcontainerservlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
      at com.ibmws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
      at com.advtechgrp.bop.medical.web.filter.UrlRewritingFilter.doFilter(UrlRewritingFilter.java:132)
      at com.ibm.ws.webcontainer.filterFilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
      at com.advtechgrp.bop.medical.web.filter.GZIPFilter.doFilter(GZIPFilter.java:36)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
      at com.advtechgrp.bop.medical.web.filter.WebLogFilter.doFilter(WebLogFilter.java:69)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
      at com.advtechgrp.bop.medical.web.filter.SecurityFilter.doFilter(SecurityFilter.java:174)
      at com.ibm.ws.webcontainerfilter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:771)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:679)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:546)
      at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
      at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
      at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1455)
      at com.ibmws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:115)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
      at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
      at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
      at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
      at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
      at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
      at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
      at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
      at com.ibmio.async.ResultHandler$2.run(ResultHandler.java:873)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)

Thanks,
Tom

A: 

Hum... this is a case of concurrent access to something that isn't thread-safe. I can't tell you more until I see the code, or at least a schematic of your software, though.

Varkhan
This exception is not related to thread safety, but modifications of the backing store while using the iterator.
Robin
We had a static variable in the report, that is a problem!!! In our next release we are going to use JasperReport 3.5. Thank you all for your help.
@Robin, although you certainly can have a concurrent modification exception without threads, threads are generally the most likely cause, especially when something is described as "occasional."
Yishai
@Yishai - I agree that it is a common cause, but certainly not the only one. Different program flow (based on application state) on a single thread can also cause this "occasionally". The point I was making was that you (not you personally) should not jump to the conclusion that the Concurrent in ConcurrentModificationException has anything to do with threading, which it doesn't. This appears to be the assumption made in the answer and it is incorrect.
Robin
+1  A: 

JasperReports is now on version 3.5, so it may be worth checking whether changes post 2.0.5 (your version) have addressed any threading issues. That obviously won't resolve your current production issue, but a rebuild with the new version might.

Having said all that (and not being familiar with JasperReports) I would suspect client-threaded code.

Brian Agnew
+1  A: 

This is caused by the backing store of the iterator being altered while the iterator is in use. This is not a concurrency problem related to threading, as it is easy enough to do on a single thread as well.

More detailed description on this question

Your biggest problem now will be if it is fixable by you or a bug in the Jasper code.

Robin