0 Replies Latest reply on May 27, 2016 10:47 AM by Thomas Schaper

    JSR 352/JBeret: Is the handling of skippable-exception-classes in JBoss EAP 7 correct?

    Thomas Schaper Newbie

      Hi everybody,


      I am new to the JBoss developer community but I've been using JBoss for more than 8 years now.


      During the last few weeks I was concerned with the JSR 352 implementation built into JBoss EAP 7. I read a lot of tutorials about it and implemented a small batch job example in order to gain some practical experience.


      The batch job that I implemented was quite simple: Importing person data (consisting of forename, surname and e-mail address) from a CSV file into JBoss' built-in HSQL database. But I did not want the example to be too simplistic and decided that the job should do a syntactical validation of the e-mail address using Hibernate Validator.


      For writing to the database I implemented an ItemWriter making use of JPA:


      public class JpaItemWriter extends AbstractItemWriter {



          private Logger logger;


          private EntityManager entityManager;



          public void writeItems(List<Object> list) {

              logger.debug("writeItems: {}", list);


              for (Object person : list) {






      My job defintion file looked like this:


      <job id="importJob" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/jobXML_1_0.xsd" version="1.0">

          <step id="importItems">

              <chunk item-count="5">

                  <reader ref="csvItemReader">


                          <property name="input.file" value="#{jobParameters['input.file']}"/>



                  <processor ref="recordToModelConverter"/>

                  <writer ref="jpaItemWriter"/>


                      <include class="javax.validation.ConstraintViolationException"/>






      For testing I created a small CSV file with fictitious sample data:







      Fowler;Amy Farah;amy.fowler@government.gov



      Now for the problem: The job should skip the fifth record because the e-mail address is invalid there.This works fine if the chunk size (itzem-count) is set to 1 in the job definition file. But as soon as I set the chunk size to a value greater than 1 the job does not work anymore as expected: Not only the bad record is skipped but also the other good records that are contained in the same chunk!!!


      In case of a skippable exception thrown by the ItemWriter the JSR 352 implementation should rollback the transaction, split the current chunk and retry the write operation with mini-chunks of size 1. But JBoss does not do this: All items in the chunk are skipped and a "retrial with mini-chunks" does not happen!


      IMHO this cannot be correct. Does anymore have an idea concerning this issue?


      Best regards



      (I have attached the complete source code of my batch processing example.)