Skip to content

Unable to read XML data without spring-tx in the classpath #4132

Closed
@fmbenhassine

Description

@fmbenhassine

Bug description

Trying to read an XML file and unmarshall data to domain objects with spring-oxm/xstream does not work without having spring-tx in the classpath. The attached minimal complete example works as expected when spring-tx is in the classpath but fails with the following exception when spring-tx is not in the classpath:

java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessResourceFailureException
    at org.springframework.batch.item.xml.StaxEventItemReader.doOpen (StaxEventItemReader.java:241)
    at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open (AbstractItemCountingItemStreamItemReader.java:150)
    at com.example.demo.DemoApplication.main (DemoApplication.java:31)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DataAccessResourceFailureException
    at java.net.URLClassLoader.findClass (URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:418)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:351)
    at org.springframework.batch.item.xml.StaxEventItemReader.doOpen (StaxEventItemReader.java:241)
    at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open (AbstractItemCountingItemStreamItemReader.java:150)
    at com.example.demo.DemoApplication.main (DemoApplication.java:31)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:748)

Environment

  • Java 8
  • Spring Batch version: 4.3.6
  • Spring Framework version: 5.3.20

Steps to reproduce

See the attached minimal complete example.

From an IDE

Load the project and run the com.example.demo.DemoApplication without any argument.

From the CLI

$> mvn package
$> mvn exec:java -Dexec.mainClass=com.example.demo.DemoApplication

Expected behavior

spring-tx should not be required to read an XML file.

Minimal Complete Reproducible example

issue-spring-oxm-without-spring-tx.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions