Skip to content

StaxEventItemWriter.unclosedHeaderCallbackElements prevents new job execution #4044

Closed
@Alex4i

Description

@Alex4i

While upgrading to spring-batch 4.3.4, my job started to fail with the exception :
The class with javax.xml.namespace.QName and name of javax.xml.namespace.QName is not trusted.

After investigating, it turns out that StaxEventItemWriter (with saveState=true) writes unclosed elements from the header callback to the step context as QNames. On the next job execution, it will first try to read the last job execution and this is where the exception appears as the step execution from StaxEventItemWriter cannot be deserialized.

This was not a problem before 4.3.4 as SimpleJobExplorer#getLastJobExecution did not fetch step executions (see #3943) but now that it does, it means that StaxEventItemWriter is not usable with a header callback out-of-the-box. EIther we have to set saveState=false on the writer, or we must create a BatchConfigurer to add the mixIn for QName to the ObjectMapper.

I think that at the very least, documentation should reflect this.

Minimal example : https://github.com/Alex4i/staxwriter_qname
Run with gradlew bootRun

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions