編集
問題を再現するテスト プロジェクトを作成しました。https://github.com/tomverelst/test-batchで見つけることができます。
最初に maven コマンドexec:javaを実行して、HSQL データベースを開始します。次に、JUnit テストを実行してMigrationJobConfigurationTest、Spring アプリケーション コンテキストをロードできます。
元の質問
Spring Batch アプリケーションを開始すると、Spring がジョブの構成をロードしているときに次の例外が発生します。
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.sun.proxy.$Proxy34]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy34
@StepScopeこれは、ジョブの構成の注釈が原因です。すでにJDKプロキシでプロキシされているCGLIBを使用してクラスをプロキシしようとしますが、このJDKプロキシがどこから来ているのかわかりません。
も使用してみ@Scope(value = "step", proxyMode = ScopedProxyMode.NO)ましたが、JDK プロキシを呼び出すとスタック オーバーフロー エラーが発生し、それ自体が呼び出され続けます。
注釈を削除すると、アプリケーションは正しく起動します@StepScopeが、ジョブに使用できるようにする必要があります。
春の設定
<context:component-scan base-package="com.jnj.rn2.batch" />
<context:annotation-config />
<aop:aspectj-autoproxy proxy-target-class="true" />
<bean class="org.springframework.batch.core.scope.StepScope" />
// Job repository etc
...
移行ジョブ構成
@Configuration
public class MigrationJobConfiguration {
    @Autowired
    private JobBuilderFactory jobs;
    @Autowired
    private StepBuilderFactory steps;
    @Autowired
    private MigrationService migrationService;
    @Bean
    public Job migrationJob() {
        return jobs.get( "migrationJob" )
            .start( migrateCrfStep() )
            .next( indexRequestsStep() )
            .build();
    }
    @Bean
    public Step migrateCrfStep() {
        return steps.get( "migrateCrfStep" )
            .tasklet( migrateCrfTasklet() )
            .build();
    }
    @Bean
    public Step indexRequestsStep() {
        return steps.get( "indexRequestsStep" )
            .<LegacyRequest,LegacyRequest> chunk( 5 )
            .reader( indexRequestReader() )
            .processor( indexRequestProcessor() )
            .writer( indexRequestWriter() )
            .build();
    }
    @Bean
    @StepScope
    public MigrateCrfTasklet migrateCrfTasklet() {
        return new MigrateCrfTasklet();
    }
    @Bean
    @StepScope
    public IndexRequestItemReader indexRequestReader() {
        return new IndexRequestItemReader();
    }
    @Bean
    @StepScope
    public IndexRequestItemProcessor indexRequestProcessor() {
        return new IndexRequestItemProcessor();
    }
    @Bean
    @StepScope
    public IndexRequestItemWriter indexRequestWriter() {
        return new IndexRequestItemWriter();
    }
    // Setters
    ...
}