首页 > 解决方案 > Spring batch 2.4.1 + Wildfly 20 final - java.lang.NoSuchFieldError: BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES

问题描述

我正在尝试在 Wildfly server 20 final 上执行 Spring 批处理应用程序,但出现以下错误,

如果我使用内置的 tomcat 服务器,相同的代码可以正常工作。

Caused by: java.lang.NoSuchFieldError: BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES
    at org.springframework.batch.core.repository.dao.Jackson2ExecutionContextStringSerializer.<init>(Jackson2ExecutionContextStringSerializer.java:119)
    at org.springframework.batch.core.repository.support.JobRepositoryFactoryBean.afterPropertiesSet(JobRepositoryFactoryBean.java:192)
    at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.createJobRepository(BasicBatchConfigurer.java:133)
    at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.initialize(BasicBatchConfigurer.java:101)
    at org.springframework.boot.autoconfigure.batch.BasicBatchConfigurer.afterPropertiesSet(BasicBatchConfigurer.java:95)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1847)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784)

标签: javaspring-batch

解决方案


I get this problem too, it looks like springbatch 4.3.0 has introduced a dependency on jackson databind 2.11.

Here's the spring commit: https://github.com/spring-projects/spring-batch/commit/9a79b4572d0aa4bec38fe90957c850920b7f9cea

And the databind commit: https://github.com/FasterXML/jackson-databind/commit/fa402574f99daa10410682160365df0867abe4d4

-> So need to downgrade to 4.2.x or upgrade jackson to 2.11

(Updated: Commit was introduced in springbatch 4.3.0, not 4.3.1)


推荐阅读