title: updating spring boot 1.2 to 1.3 and adding batch jobs to spring cloud dataflow task
body: <p>We have multiple batch jobs we use which have been configured using spring boot 1.2.0 and used with spring batch admin. We are now trying to convert these jobs to tasks so that we can implement them in spring cloud dataflow. For this, I update the spring boot from 1.2.0 to 1.3.2. I added the @EnableTask annotation after which it recognizes it as a task but when the batch job runs and i click the jobs tab on the UI, the scdf server gives an error saying "Spring batch application ran which wasn't a Task". For this, I also added the @EnableBatchProcessing to the main application. After which I am getting the following error: </p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error 
  creating bean with name 'jobBuilders' defined in class path resource [org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.batch.core.configuration.annotation.JobBuilderFactory]: Factory method 'jobBuilders' threw exception; nested exception is java.lang.ClassCastException: org.springframework.batch.core.repository.support.JobRepositoryFactoryBean$$EnhancerBySpringCGLIB$$6151f9ab cannot be cast to org.springframework.batch.core.repository.JobRepository
  at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.2.RELEASE.jar!/:1.3.2.RELEASE]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) ~[spring-boot-1.3.2.RELEASE.jar!/:1.3.2.RELEASE]
  at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) ~[spring-boot-1.3.2.RELEASE.jar!/:1.3.2.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-1.3.2.RELEASE.jar!/:1.3.2.RELEASE]
  at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) [spring-boot-1.3.2.RELEASE.jar!/:1.3.2.RELEASE]
  at com.mediaiq.appnexus.batch.AppnexusBatchServiceApplication.main(AppnexusBatchServiceApplication.java:43) [classes!/:na]
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
  at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
  at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [aiq-appnexus-batch-service-3.24-SNAPSHOT.jar:na]
  at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [aiq-appnexus-batch-service-3.24-SNAPSHOT.jar:na]
  at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [aiq-appnexus-batch-service-3.24-SNAPSHOT.jar:na]
  at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [aiq-appnexus-batch-service-3.24-SNAPSHOT.jar:na]
  Caused by: org.springframework.beans.BeanInstantiationException: 
  Failed to instantiate [org.springframework.batch.core.configuration.annotation.JobBuilderFactory]: Factory method 'jobBuilders' threw exception; nested exception is java.lang.ClassCastException: org.springframework.batch.core.repository.support.JobRepositoryFactoryBean$$EnhancerBySpringCGLIB$$6151f9ab cannot be cast to org.springframework.batch.core.repository.JobRepository
  at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  ... 25 common frames omitted
  Caused by: java.lang.ClassCastException: org.springframework.batch.core.repository.support.JobRepositoryFactoryBean$$EnhancerBySpringCGLIB$$6151f9ab cannot be cast to org.springframework.batch.core.repository.JobRepository
  at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$$EnhancerBySpringCGLIB$$96003aa6.jobRepository(&lt;generated&gt;) ~[spring-batch-core-3.0.6.RELEASE.jar!/:3.0.6.RELEASE]
  at org.springframework.batch.core.configuration.annotation.AbstractBatchConfiguration.jobBuilders(AbstractBatchConfiguration.java:58) ~[spring-batch-core-3.0.6.RELEASE.jar!/:3.0.6.RELEASE]
  at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$$EnhancerBySpringCGLIB$$96003aa6.CGLIB$jobBuilders$6(&lt;generated&gt;) ~[spring-batch-core-3.0.6.RELEASE.jar!/:3.0.6.RELEASE]
  at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$$EnhancerBySpringCGLIB$$96003aa6$$FastClassBySpringCGLIB$$12ef6ed8.invoke(&lt;generated&gt;) ~[spring-batch-core-3.0.6.RELEASE.jar!/:3.0.6.RELEASE]
  at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:355) ~[spring-context-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$$EnhancerBySpringCGLIB$$96003aa6.jobBuilders(&lt;generated&gt;) ~[spring-batch-core-3.0.6.RELEASE.jar!/:3.0.6.RELEASE]
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
  at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
  at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
  ... 26 common frames omitted
  </code></pre>
  
  <p>These are my current pom.xml dependencies: </p>
  
  <pre><code>&lt;dependencyManagement&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
              &lt;version&gt;1.3.2.RELEASE&lt;/version&gt;
              &lt;type&gt;pom&lt;/type&gt;
              &lt;scope&gt;import&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-core&lt;/artifactId&gt;
              &lt;version&gt;${logback.version}&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.mariadb.jdbc&lt;/groupId&gt;
          &lt;artifactId&gt;mariadb-java-client&lt;/artifactId&gt;
          &lt;version&gt;2.2.3&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
          &lt;artifactId&gt;spring-cloud-task-core&lt;/artifactId&gt;
          &lt;version&gt;2.0.0.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.zaxxer&lt;/groupId&gt;
          &lt;artifactId&gt;HikariCP&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.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-jersey&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security.oauth&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-oauth2&lt;/artifactId&gt;
          &lt;version&gt;2.0.8.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-jwt&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>I am also using a modified spring batch infra which has the following config.xml file defined: </p>
  
  <pre><code>&lt;bean id="jobRepository"
      class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"&gt;
      &lt;property name="transactionManager" ref="transactionManager" /&gt;
      &lt;property name="databaseType" value="mysql" /&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jobLauncher"
      class="org.springframework.batch.core.launch.support.SimpleJobLauncher"&gt;
      &lt;property name="jobRepository" ref="jobRepository" /&gt;
  &lt;/bean&gt;
  
  &lt;task:executor id="asyncBatchJobExecutor" pool-size="4" /&gt;
  
  &lt;bean id="asyncJobLauncher"
      class="org.springframework.batch.core.launch.support.SimpleJobLauncher"&gt;
      &lt;property name="jobRepository" ref="jobRepository" /&gt;
      &lt;property name="taskExecutor" ref="asyncBatchJobExecutor" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jobRegistry"
      class="org.springframework.batch.core.configuration.support.MapJobRegistry" /&gt;
  
  &lt;bean
      class="org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor"&gt;
      &lt;property name="jobRegistry" ref="jobRegistry" /&gt;
  &lt;/bean&gt;
  
  &lt;bean class="org.springframework.batch.core.scope.JobScope" id="jobScope" /&gt;
  
  &lt;bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"&gt;
      &lt;property name="scopes"&gt;
          &lt;map&gt;
              &lt;entry key="job"&gt;
                  &lt;ref bean="jobScope" /&gt;
              &lt;/entry&gt;
          &lt;/map&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jpaBatchWriter" class="org.springframework.batch.item.database.JpaItemWriter"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jobExplorer"
      class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>