title: Spring Integration Java DSL problems at startup with Http Outbound Gateway
body: <p>I'm new to Spring Integration and am trying to develop an application which simply (1) polls a folder for new files with extension <code>.dat</code> containing data in csv format (2) initialize for each line a domain POJO object of class <code>RecordDTO</code> and finally (3) sends this object as payload to a REST service with a POST.</p>
  
  <p>For this I'm trying to use Java DSL for Spring Integration.</p>
  
  <p>The problem I'm getting is the following <code>VerifyError</code> / <code>HttpRequestExecutingMessageHandler overrides final method onInit.</code> exception. </p>
  
  <pre><code>2016-07-22 10:01:38.965 ERROR 4460 --- [           main] o.s.boot.SpringApplication               : Application startup failed
  
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'upcase' defined in eu.softeco.examples.SpringBootIntegrationTestApplication: Initialization of bean failed; nest
  ed exception is java.lang.VerifyError: class org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler overrides final method onInit.()V
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
  
  ...
  
  Caused by: java.lang.VerifyError: class org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler overrides final method onInit.()V
      at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_45]
      at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_45]
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_45]
  
  ...
  </code></pre>
  
  <p>Below are relevant details concerning my code and maven configuration. Please not that </p>
  
  <p>1) the problem is at startup, before any data is put in the input folder</p>
  
  <p>2) if I replace the final Http outboundGateway step with the simple (commented) System.out.println, everything works fine.</p>
  
  <p>Following are code/config details. This is my main Spring Boot application class with Spring Integration Flow definition:</p>
  
  <pre><code>@SpringBootApplication
  @EnableIntegration 
  @IntegrationComponentScan
  public class SpringBootIntegrationTestApplication {
  
          ...
  
      public static void main(String[] args) {
            SpringApplication.run(SpringBootIntegrationTestApplication.class, args);
      }
  
      /**
       * Inbound FileReadingMessageSource 
       */
  
      @Bean
      @InboundChannelAdapter(channel = "upcase.input", poller = @Poller(fixedDelay = "4000"))
      public MessageSource&lt;File&gt; fileReadingMessageSource() {
           FileReadingMessageSource source = new FileReadingMessageSource();
           source.setDirectory(new File(INBOUND_PATH));
           source.setFilter(new SimplePatternFileListFilter("*.dat"));
           return source;
      }
  
  
      /**
       * Spring Integration Java DSL Flow
           */
  
      @Bean
      public IntegrationFlow upcase() {
  
          FileToStringTransformer fileToStringTranformer = Transformers.fileToString();
          fileToStringTranformer.setDeleteFiles(true);
  
              return flow -&gt; flow
  
                      // get string contents from fie 
                      .transform(fileToStringTranformer) 
  
                      // split into individual lines
                      .split( s -&gt; s.applySequence(true).get().getT2().setDelimiters("\n"))
  
                      // cleanup lines from trailing returns
                      .transform( (String s) -&gt; s.replace("\n", "").replace("\r", "") )
  
                      // convert csv string to RecordDTO object
                      .transform("@recordFromCsvTransformer.transform(payload)")
  
                      // print on System.out
                      // .handle(m -&gt; System.out.println(m.getPayload()))
  
                      // send to 
                      .handle(Http.outboundGateway("http://localhost:8080/records")
                                  .httpMethod(HttpMethod.POST)
                          .expectedResponseType(RecordDTO.class));
  
  
      }
  
  }
  </code></pre>
  
  <p>Below the <code>RecordFromCsvTransformer</code> class </p>
  
  <pre><code>@Component
  public class RecordFromCsvTransformer
  {
      @Transformer
      public RecordDTO transform(String csvline) throws Exception {
  
          RecordDTO record = new RecordDTO();
  
          ... parse csv and initialize record's fields...
  
          return record;
      }
  
  }
  </code></pre>
  
  <p>And Finally the relevant parts of <code>pom.xml</code> (dependencies);</p>
  
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.4.0.RC1&lt;/version&gt;
      &lt;relativePath /&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  
  ...
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-integration&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.integration&lt;/groupId&gt;
          &lt;artifactId&gt;spring-integration-file&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.integration&lt;/groupId&gt;
          &lt;artifactId&gt;spring-integration-http&lt;/artifactId&gt;
          &lt;version&gt;2.1.0.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      ...
  &lt;/dependencies&gt;
  
  ...
  </code></pre>
  
  <p>As a side question in general, can someone suggest me some good tutorial / getting started guide to learn Spring Integration with Java Annotation/Java DSL? So far I've only found either introductory guide based on Spring Integration XML configuration or material about Java Annotations/DSL but that already requires prior knowledge of Spring Integration.</p>