Announcement Announcement Module
Collapse
No announcement yet.
XML document structures must start and end within the same entity Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • XML document structures must start and end within the same entity

    Hello,

    I am using Spring-batch 1.1.4 RELEASE and I have stumbled across an error while parsing a XML file with StaxEventItemReader. I have tried using different marshallers but with the same result.

    My bean
    Code:
     <bean id="fundCompanyReaderCastor" class="org.springframework.batch.item.xml.StaxEventItemReader">
            <property name="fragmentRootElementName" value="fundcompany" />
            <property name="resource" value="file://FundCompanies.xml" />
            <property name="fragmentDeserializer">
                <bean class="org.springframework.batch.item.xml.oxm.UnmarshallingEventReaderDeserializer">
                    <constructor-arg>
                        <bean class="org.springframework.oxm.castor.CastorMarshaller">
                            <property name="targetClass" value="se.model.FundCompany"/>
                            <property name="ignoreExtraAttributes" value="true"/>
                            <property name="ignoreExtraElements" value="true"/>
                        </bean>
                    </constructor-arg>
                </bean>
            </property>
        </bean>
    The reader parses my XML file but on the last element the following exception is thrown. (The XML file is valid according to my XML tools)

    Code:
    2009-04-29 10:58:07,643 ERROR [main] org.springframework.batch.core.step.AbstractStep - Encountered an error executing the step: class org.springframework.dao.DataAccessResourceFailureException: Error while reading from event reader; nested exception is javax.xml.stream.XMLStreamException: ParseError at [row,col]:[48959,15]
    Message: XML document structures must start and end within the same entity.
    org.springframework.dao.DataAccessResourceFailureException: Error while reading from event reader; nested exception is javax.xml.stream.XMLStreamException: ParseError at [row,col]:[48959,15]
    Message: XML document structures must start and end within the same entity.
    	at org.springframework.batch.item.xml.StaxEventItemReader.moveCursorToNextFragment(StaxEventItemReader.java:122)
    	at org.springframework.batch.item.xml.StaxEventItemReader.doRead(StaxEventItemReader.java:168)
    	at org.springframework.batch.item.support.AbstractBufferedItemReaderItemStream.read(AbstractBufferedItemReaderItemStream.java:92)
    	at org.springframework.batch.item.file.MultiResourceItemReader.readNextItem(MultiResourceItemReader.java:124)
    	at org.springframework.batch.item.file.MultiResourceItemReader.read(MultiResourceItemReader.java:94)
    	at org.springframework.batch.item.support.DelegatingItemReader.read(DelegatingItemReader.java:61)
    	at org.springframework.batch.core.step.item.BatchListenerFactoryHelper$1.read(BatchListenerFactoryHelper.java:67)
    	at org.springframework.batch.core.step.item.SimpleItemHandler.doRead(SimpleItemHandler.java:88)
    	at org.springframework.batch.core.step.item.SimpleItemHandler.read(SimpleItemHandler.java:80)
    	at org.springframework.batch.core.step.item.SimpleItemHandler.handle(SimpleItemHandler.java:66)
    	at org.springframework.batch.core.step.item.ItemOrientedStep$3.doInIteration(ItemOrientedStep.java:391)
    	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:346)
    	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212)
    	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
    	at org.springframework.batch.core.step.item.ItemOrientedStep.processChunk(ItemOrientedStep.java:382)
    	at org.springframework.batch.core.step.item.ItemOrientedStep$2.doInIteration(ItemOrientedStep.java:259)
    	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:346)
    	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:212)
    	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
    	at org.springframework.batch.core.step.item.ItemOrientedStep.doExecute(ItemOrientedStep.java:236)
    	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:172)
    	at org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:103)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:86)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:81)
    	at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:205)
    	
    ....
    Anyone else experiencing this problem? My workaround so far has been to extend StaxEventItemReader and override the the moveCursorToNextFragment method where I can deal with the exception myself and return false which lets the job continue. Not nice ... I... know...

    /Jonas
    Last edited by jladenfors; Apr 29th, 2009, 10:42 AM. Reason: added code segments for future references.

  • #2
    Which version of StAX are you using (and is there maybe more than one on the classpath?). I don't recognise this issue but there have been similar problems with some providers. The reference impl, and the one in the JDK (1.6) should work.

    (Please use [code][/code] tags to post code and stack traces.)

    Comment


    • #3
      I didn't previously explicitly import any StAX dependency to my project so I can't really say which version I was using but after declaring the StAX 1.2.0 reference implementation the errors disappeared.

      Thanks for pointing me in the right direction!

      Code:
       <dependency>
                  <groupId>stax</groupId>
                  <artifactId>stax</artifactId>
                  <version>1.2.0</version>
              </dependency>

      Comment

      Working...
      X