title: Getting ConcurrentModificationException with Kyro/Activiti and Spring Integration
body: <p>I am trying out to integrate Activiti with Spring Integration. The sample provided by Josh Long works but when i try to change it, specifically MessageChannels part, it starts throwing <code>ConcurrentModificationException</code>.</p>
  
  <p>Josh Longs <a href="https://github.com/joshlong/activiti-examples" rel="nofollow">Activiti/Spring Integration example</a> here.</p>
  
  <p>As per Josh's code, MessageChannels is as follows:</p>
  
  <pre><code>@Configuration
  class MessageChannels {
  
      @Bean
      DirectChannel requests() {
          return new DirectChannel();
      }
  
      @Bean
      DirectChannel replies() {
          return new DirectChannel();
      }
  }
  </code></pre>
  
  <p>I changed this to spring integration (With Stream Rabbit) to </p>
  
  <pre><code>@Configuration
  public interface MessageChannels {
  
      @Input
      SubscribableChannel input();
  
      @Output("cooutput")
      MessageChannel createOutput();
  
  }
  </code></pre>
  
  <p>And my property file contains,</p>
  
  <pre><code>spring.cloud.stream.bindings.cooutput.destination=outputChannel
  </code></pre>
  
  <p>I am getting following exception, when i am calling "/start".</p>
  
  <pre><code>2016-09-10 16:14:39.087  INFO 73606 --- [           main] c.e.ActivitiIntegrationDemoApplication   : Started ActivitiIntegrationDemoApplication in 8.236 seconds (JVM running for 8.759)
  2016-09-10 16:15:39.524  INFO 73606 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
  2016-09-10 16:15:39.524  INFO 73606 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
  2016-09-10 16:15:39.540  INFO 73606 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 16 ms
  2016-09-10 16:15:39.598  INFO 73606 --- [nio-8080-exec-1] o.s.i.codec.kryo.CompositeKryoRegistrar  : registering [40, java.io.File] with serializer org.springframework.integration.codec.kryo.FileSerializer
  2016-09-10 16:15:39.638 ERROR 73606 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.messaging.MessageHandlingException: error occurred in message handler [org.springframework.cloud.stream.binder.rabbit.RabbitMessageChannelBinder$SendingHandler@1b59052b]; nested exception is com.esotericsoftware.kryo.KryoException: java.util.ConcurrentModificationException
  Serialization trace:
  classes (sun.misc.Launcher$AppClassLoader)
  beanClassLoader (org.springframework.context.event.SimpleApplicationEventMulticaster)
  applicationEventMulticaster (org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext)
  applicationContext (org.activiti.spring.ApplicationContextElResolver)
  resolvers (org.activiti.engine.impl.javax.el.CompositeELResolver)
  elResolver (org.activiti.engine.impl.el.ActivitiElContext)
  cachedElContext (org.activiti.engine.impl.persistence.entity.ExecutionEntity)] with root cause
  
  java.util.ConcurrentModificationException: null
      at java.util.Vector$Itr.checkForComodification(Vector.java:1184) ~[na:1.8.0_102]
      at java.util.Vector$Itr.next(Vector.java:1137) ~[na:1.8.0_102]
      at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:92) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:40) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:100) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:40) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518) ~[kryo-shaded-3.0.3.jar:na]
      at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552) ~[kryo-shaded-3.0.3.jar:na]
      at 
  </code></pre>
  
  <p>Also I have added following annotations to main class.</p>
  
  <pre><code>@SpringBootApplication
  @IntegrationComponentScan
  @EnableBinding(MessageChannels.class)
  </code></pre>