1 Reply Latest reply on Nov 17, 2019 10:49 PM by Cheng Fang

    BeanIO Reader with Validation

    Richard Moore Master

      My bean has annotations for a field to not be null. It works -


      2019-11-11 14:38:41.860 jberet-1                                  jberet - WARN  JBERET000028: Failed to serialize exception: javax.validation.ConstraintViolationException:






      Allowance2 is required



      The problem is I want to catch this as a read error and let the errorHandler take care of it so I can keep processing the file. What am I doing wrong?


      <chunk item-count="100">

      <reader ref="beanIOItemReader">


      <property name="resource" value="RPE_ThirdPartyDealsScan.csv" />

      <property name="streamName" value="ThrdPrtyDlsInputAllFlds" />

      <property name="streamMapping" value="ThrdPrtyDlsInputAllFlds.xml" />

      <property name="errorHandler" value="com.awginc.rpe.map.bean.DealScanBeanErrorHandler" />



      <writer ref="jsonItemWriter">


      <property name="resource" value="BusinessInformation.json" />

      <property name="writeMode" value="overwrite" />




        • 1. Re: BeanIO Reader with Validation
          Cheng Fang Master

          sorry for the delay.  I think what happens is the BeanIO's BeanReader reads a record, which returns an object, and this object is passed to the bean validation for checking constraints.  So the validation part happens outside BeanIO's BeanReader's read method, and hence any BeanIO errorHandler will not have an effecet on bean validation errors.  Basically, the errorHandler you're using in this case is a BeanIO construct, not one in batch/jberet.


          For more details, you can check the source code of org.jberet.support.io.BeanIOItemReader