1

when I'm trying to set a Marshaller to StaxEventItemWriterBuilder in my spring batch config file it gives me the following error in Eclipse IDE,

"The method marshaller(Marshaller) from the type StaxEventItemWriterBuilder refers to the missing type Marshaller"

related code

 @Bean
        public StaxEventItemWriter<EmployeeReport> writerTERXFCDJ(DataSource dataSource, JAXBContext jaxbContext) {
            jaxbContext = JAXBContext.newInstance(EmployeeReport.class);//class names
            Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

            return new StaxEventItemWriterBuilder<EmployeeReport>()
                    .name("employeeReportItemWriter")
                    .version("1.0")
                    .rootTagName("EmployeeReportList")
                    .resource(new FileSystemResource("a.xml"))
                    .marshaller(jaxbMarshaller)// gives error "The method marshaller(Marshaller) from the type StaxEventItemWriterBuilder<EmployeeReport> refers to the missing type Marshaller"
                    .build();

        }

additional info: Im using latest spring boot 3 app with spring batch 5

using following dependencies in pom file(only the related part)

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-batch</artifactId>
</dependency>

<dependency>
      <groupId>jakarta.xml.bind</groupId>
      <artifactId>jakarta.xml.bind-api</artifactId>
</dependency>

<!-- JAXB Implementation -->
<dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
</dependency>
    
<dependency>
         <groupId>com.sun.xml.bind</groupId>
         <artifactId>jaxb-impl</artifactId>
         <scope>runtime</scope>
</dependency>

I also notice in StaxEventItemWriter class it uses import org.springframework.oxm.Marshaller; is spring-oxm still being used in latest spring boot/batch apps? how can I fix the above mentioned error? Thanks and Any help will be greatly appreciated.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

0 Answers0