Closed sr9112 closed 2 years ago
From which version are you upgrading? What is the jackson-databind
version you have in your classpath?
Migrating from spring boot v2.2.5 to v2.6.6. The jackson-bind library version seen in the build is v2.13.2.2 when upgrading to spring boot v2.6.6. Also, tried upgrading to spring boot v2.5.12 which has jackson-bind library version 2.12.6.1. In both the cases same error is seen. Error is seen when jobRepository is being initialized during job autoconfiguration.
Thank you for your feedback. You seem to have a (manual) dependency management issue. With boot 2.2.5, you get batch 4.2.1 and jackson 2.10.2. In this case the execution context serializer does not use BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES
and the error does not happen. You can see that in the attached project.
With boot 2.6.6, you get batch 4.3.5 and jackson 2.13.2. In this case, the execution context serializer does use BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES
which is present in jackson and the error you reported does not happen neither.
So you should be overriding some versions manually. I am not able to reproduce the issue, see the attached project which lets boot manage dependencies. I'm closing this issue for now, but if you can provide a minimal reproducer, I can dig deeper. Thank you.
Minimal example: demo4091.zip
I just created a new empty project and tried run on Weblogic 12.2.1.3.0 with java 1.8.0_333 Solaris OS. The issue persists.
The maven pom.xml below belongs to the project
`<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>groupid</groupId>
<artifactId>testbatch</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>testbatch</name>
<description>testbatch</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
`
Hi, I am using spring batch 4.3.8 and using jackson-databind 2.13.4.2 version. Facing same issue. Can you please suggest to resolve this issue?
Afte upgrading spring job apps to use spring boot library v2.6.6 with spring batch v4.3.5,below error is seen while deploying the application on the server with JDK8.
_Caused by: java.lang.NoSuchFieldError: BLOCK_UNSAFE_POLYMORPHIC_BASETYPES at org.springframework.batch.core.repository.dao.Jackson2ExecutionContextStringSerializer.(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)
Steps to reproduce Upgrade to spring boot application using spring batch jobs to spring boot starter v2.6.6
Check the below link for reported issue - (https://stackoverflow.com/questions/65607909/spring-batch-2-4-1-wildfly-20-final-java-lang-nosuchfielderror-block-unsafe)