Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserialization of JobParameters throws exception #4569

Open
robmartin-scibite opened this issue Apr 2, 2024 · 0 comments
Open

Deserialization of JobParameters throws exception #4569

robmartin-scibite opened this issue Apr 2, 2024 · 0 comments
Labels
status: waiting-for-triage Issues that we did not analyse yet type: bug

Comments

@robmartin-scibite
Copy link

Bug description

When using a JobStep to call other jobs, Spring batch persists the associated JobParameters in the BATCH_STEP_EXECUTION_CONTEXT table as a serialized object.
JobParameters is Serializable but does not set its SerialVersionUID. If I attempt to load an old job execution for a composite job ( for example through JobExplorer.getJobExecution()) and the JobParameter class has changed (for example when I update the version of the Spring Batch dependency) then I get the following error:

Caused by: java.io.InvalidClassException: org.springframework.batch.core.JobParameters; local class incompatible: stream classdesc serialVersionUID = -2301555723671712749, local class serialVersionUID = 9157654800004870848
	at java.base/java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:597)
	at java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2051)
	at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1898)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2224)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:509)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:467)
	at java.base/java.util.HashMap.readObject(HashMap.java:1552)
	at java.base/jdk.internal.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1100)
	at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2423)
	at java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2257)
	at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:509)
	at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:467)
	at org.springframework.batch.core.repository.dao.DefaultExecutionContextSerializer.deserialize(DefaultExecutionContextSerializer.java:81)
	... 193 common frames omitted

Environment
Spring Batch 5.0.5
Java 17
Postgres bitnami/postgresql:13.10.0

Steps to reproduce
Run a Job containing a JobStep (which calls another job) on Spring Batch version 5.0.1
Update to Spring batch 5.0.5
Load the job using JobExplorer.getJobExecution()

Expected behavior
The job execution should be loaded from the database

@robmartin-scibite robmartin-scibite added status: waiting-for-triage Issues that we did not analyse yet type: bug labels Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage Issues that we did not analyse yet type: bug
Projects
None yet
Development

No branches or pull requests

1 participant