Issue Details (XML | Word | Printable)

Key: JS2-17
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: David Sean Taylor
Reporter: Ate Douma
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Jetspeed 2

ava.util.ConcurrentModificationException during parallel Portlet rendering

Created: 21/Apr/04 12:15 PM   Updated: 08/Dec/05 12:40 PM
Return to search
Component/s: Container
Affects Version/s: 2.0-dev/cvs
Fix Version/s: None

Time Tracking:
Not Specified

Environment: WindowsXP, J2SE1.4.2_03, Tomcat 4.1.29

Resolution Date: 08/Dec/05 12:40 PM


 Description  « Hide
I now have encountered this exception multiple times so I dived into it what was going on here.

It turns out that the parallel rendering of portlets isn't thread save.
When the rendering of a portlet is dispatched through Tomcat by o.a.j.container.invoker.ServletPortletInvoker.invoke Tomcat will create its own wrappers around the supplied request and response parameters. While doing that, it retrieves the attributes from the request which are stored in a HashMap.
But, as this HashMap is seemingly shared by all portlets (from the base request probably) this CAN lead to thread unsave situations with parallel rendering and I've encountered this now rather often.

A don't have a clear solution right now but what maybe could help is ensuring that the already request wrapper passed on to Tomcat for rendering doesn't fall back on shared Maps for its attributes (and parameters probably). So, for each portlet a separate wrapped request is needed which has its own HashMap of attributes and parameters. Most likely then this won't break anymore.

Warning: I've seen in parts of the request handling code of Catalina (Tomcat 4) that it unwraps request objects until it finds the original one created by Catalina itself. If that's been done here as well no real protection against this problem can be created and the parallel rendering is in trouble.

An example snippet including stacktrace of the exception from jetspeed.log:

2004-04-20 11:32:48,328 [WORKER_13] DEBUG org.apache.jetspeed.aggregator.impl.Worker - Processing job for window :15
2004-04-20 11:32:48,328 [WORKER_13] DEBUG org.apache.jetspeed.aggregator.impl.RenderingJob - Rendering OID 15 org.apache.jetspeed.engine.servlet.ServletRequestImpl@c22978 org.apache.jetspeed.aggregator.impl.HttpBufferedResponse@130b5e2
2004-04-20 11:32:48,328 [WORKER_13] ERROR org.apache.jetspeed.container.invoker.ServletPortletInvoker - Failed to dispatch.include for Portlet Application: /struts-demo, servlet: /container
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782)
at java.util.HashMap$KeyIterator.next(HashMap.java:818)
at org.apache.catalina.util.Enumerator.nextElement(Enumerator.java:217)
at org.apache.catalina.core.ApplicationHttpRequest.setRequest(ApplicationHttpRequest.java:514)
at org.apache.catalina.core.ApplicationHttpRequest.<init>(ApplicationHttpRequest.java:125)
at org.apache.catalina.core.ApplicationDispatcher.wrapRequest(ApplicationDispatcher.java:921)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:547)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:498)
at org.apache.jetspeed.container.invoker.ServletPortletInvoker.invoke(ServletPortletInvoker.java:208)
at org.apache.jetspeed.container.invoker.ServletPortletInvoker.render(ServletPortletInvoker.java:122)
at org.apache.pluto.PortletContainerImpl.renderPortlet(PortletContainerImpl.java:107)
at org.apache.jetspeed.container.JetspeedPortletContainerWrapper.renderPortlet(JetspeedPortletContainerWrapper.java:98)
at org.apache.jetspeed.aggregator.impl.RenderingJob.run(RenderingJob.java:109)
at org.apache.jetspeed.aggregator.impl.Worker.run(Worker.java:142)
2004-04-20 11:32:48,328 [WORKER_13] ERROR org.apache.jetspeed.aggregator.impl.RenderingJob - Error rendering portlet OID 15
javax.portlet.PortletException: Failed to dispatch.include for Portlet Application: /struts-demo, servlet: /container
at org.apache.jetspeed.container.invoker.ServletPortletInvoker.invoke(ServletPortletInvoker.java:215)
at org.apache.jetspeed.container.invoker.ServletPortletInvoker.render(ServletPortletInvoker.java:122)
at org.apache.pluto.PortletContainerImpl.renderPortlet(PortletContainerImpl.java:107)
at org.apache.jetspeed.container.JetspeedPortletContainerWrapper.renderPortlet(JetspeedPortletContainerWrapper.java:98)
at org.apache.jetspeed.aggregator.impl.RenderingJob.run(RenderingJob.java:109)
at org.apache.jetspeed.aggregator.impl.Worker.run(Worker.java:142)
Caused by: java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782)
at java.util.HashMap$KeyIterator.next(HashMap.java:818)
at org.apache.catalina.util.Enumerator.nextElement(Enumerator.java:217)
at org.apache.catalina.core.ApplicationHttpRequest.setRequest(ApplicationHttpRequest.java:514)
at org.apache.catalina.core.ApplicationHttpRequest.<init>(ApplicationHttpRequest.java:125)
at org.apache.catalina.core.ApplicationDispatcher.wrapRequest(ApplicationDispatcher.java:921)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:547)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:498)
at org.apache.jetspeed.container.invoker.ServletPortletInvoker.invoke(ServletPortletInvoker.java:208)
... 5 more
Nested Exception is
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:782)
at java.util.HashMap$KeyIterator.next(HashMap.java:818)
at org.apache.catalina.util.Enumerator.nextElement(Enumerator.java:217)
at org.apache.catalina.core.ApplicationHttpRequest.setRequest(ApplicationHttpRequest.java:514)
at org.apache.catalina.core.ApplicationHttpRequest.<init>(ApplicationHttpRequest.java:125)
at org.apache.catalina.core.ApplicationDispatcher.wrapRequest(ApplicationDispatcher.java:921)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:547)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:498)
at org.apache.jetspeed.container.invoker.ServletPortletInvoker.invoke(ServletPortletInvoker.java:208)
at org.apache.jetspeed.container.invoker.ServletPortletInvoker.render(ServletPortletInvoker.java:122)
at org.apache.pluto.PortletContainerImpl.renderPortlet(PortletContainerImpl.java:107)
at org.apache.jetspeed.container.JetspeedPortletContainerWrapper.renderPortlet(JetspeedPortletContainerWrapper.java:98)
at org.apache.jetspeed.aggregator.impl.RenderingJob.run(RenderingJob.java:109)
at org.apache.jetspeed.aggregator.impl.Worker.run(Worker.java:142)
2004-04-20 11:32:48,328 [WORKER_13] DEBUG org.apache.jetspeed.aggregator.impl.ContentDispatcherImpl - Notifying complete OID 15



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #186505 Wed May 12 18:46:53 UTC 2004 taylor implemented a sequential strategy in PageAggregator
Parallel fails on Tomcat 5 due to bug JS2-17

http://nagoya.apache.org/jira/browse/JS2-17

J2 is now running on Tomcat 5, if you set your aggregation strategy to sequential
I made sequential the default aggregation strategy until we can clear up JS2-17 and run parallel correctly

This closes bug JS2-6

http://nagoya.apache.org/jira/browse/JS2-6

PR:
Obtained from:
Submitted by:
Reviewed by:
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Files Changed
MODIFY /portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/aggregator/impl/ContentDispatcherImpl.java
MODIFY /portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/aggregator/impl/PageAggregatorImpl.java
MODIFY /portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/aggregator/ContentDispatcher.java