Seeing ConcurrentModificationException occasionally when deploying RESTEasy application in JBoss EAP 6
Environment
Red Hat JBoss Enterprise Application Platform (EAP) 6.4
Issue
- During server startup, while multiple artifacts are being deployed in parallel by the server, a ConcurrentModificationException occurs that prevents an artifact from being correctly deployed :
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/test-app]] (ServerService Thread Pool -- 45) JBWEB000287: Exception sending context initialized event to listener instance of class org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap: java.lang.RuntimeException: java.lang.RuntimeException: RESTEASY001795: Unable to instantiate MessageBodyReader
at org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:32) [resteasy-jaxrs-2.3.12.Final-redhat-1.jar:]
at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:219) [resteasy-jaxrs-2.3.12.Final-redhat-1.jar:]
at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:28) [resteasy-jaxrs-2.3.12.Final-redhat-1.jar:]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.5.12.Final-redhat-1.jar:7.5.12.Final-redhat-1]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3780) [jbossweb-7.5.12.Final-redhat-1.jar:7.5.12.Final-redhat-1]
at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:163) [jboss-as-web-7.5.5.Final-redhat-3.jar:7.5.5.Final-redhat-3]
at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:61) [jboss-as-web-7.5.5.Final-redhat-3.jar:7.5.5.Final-redhat-3]
at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:96) [jboss-as-web-7.5.5.Final-redhat-3.jar:7.5.5.Final-redhat-3]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_45]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_45]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.lang.RuntimeException: RESTEASY001795: Unable to instantiate MessageBodyReader
at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:837) [resteasy-jaxrs-2.3.12.Final-redhat-1.jar:]
at org.jboss.resteasy.plugins.providers.RegisterBuiltin.registerProviders(RegisterBuiltin.java:67) [resteasy-jaxrs-2.3.12.Final-redhat-1.jar:]
at org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:28) [resteasy-jaxrs-2.3.12.Final-redhat-1.jar:]
... 13 more
Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList.sort(ArrayList.java:1456) [rt.jar:1.8.0_45]
at java.util.Collections.sort(Collections.java:141) [rt.jar:1.8.0_45]
at org.jboss.resteasy.core.MediaTypeMap.add(MediaTypeMap.java:281) [resteasy-jaxrs-2.3.12.Final-redhat-1.jar:]
at org.jboss.resteasy.spi.ResteasyProviderFactory.addMessageBodyReader(ResteasyProviderFactory.java:518) [resteasy-jaxrs-2.3.12.Final-redhat-1.jar:]
at org.jboss.resteasy.spi.ResteasyProviderFactory.addMessageBodyReader(ResteasyProviderFactory.java:480) [resteasy-jaxrs-2.3.12.Final-redhat-1.jar:]
at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:833) [resteasy-jaxrs-2.3.12.Final-redhat-1.jar:]
... 15 more
Resolution
Apply JBoss EAP 6.4 Cumulative Patch (CP) 7 or later
Root Cause
This content is not included.bz-1291983 : ConcurrentModificationException in MediaTypeMap.convert()
Content from issues.jboss.org is not included.RESTEASY-762: ConcurrentModificationException in MediaTypeMap.convert()
Content from issues.jboss.org is not included.RESTEASY-1139: Another ConcurrentModificationException on parallel deployments in InterceptorRegistry
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.