Skip to content

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

Closed
@fmbenhassine

Description

@fmbenhassine
Contributor

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

Activity

added this to the 5.0.0 milestone on Jun 30, 2022
added 2 commits that reference this issue on Jul 7, 2022
fbf15a4
82af6e0
modified the milestones: 5.0.0, 5.0.0-M4 on Jul 18, 2022
added a commit that references this issue on Jul 18, 2022
1e24e38
added a commit that references this issue on Feb 15, 2024
adbc39a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Participants

      @fmbenhassine

      Issue actions

        Unable to read XML data without spring-tx in the classpath · Issue #4132 · spring-projects/spring-batch