Announcement Announcement Module
No announcement yet.
itemreader validation Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • itemreader validation


    I am new to Spring batch and was trying to find the way to validate the Flatfile data. My requirement is to validate the flatfile record for the invalid column data like number expected but a alpha numeric is present. This will fail in the fieldset readDouble function. But I want an exception mechanisum so that it will let me know which field is having this problem. With the skipListener I am able to get the error and the line that is failing, but I want to know exactly which field conversion is throwing this error message.

    I tried using BeanWrapperFieldSetMapper, even that is not giving exact field conversion error.

    Can some you pelase point me to where I can find documentation for such implementation.

    Advance thanks


  • #2

    I had tried the same. I found some code on net. I had modified slightly , and I able to find the field-wise conversion error messages.
    The code is

    public void onSkipInRead(final Throwable e) {
            if (e instanceof FlatFileParseException) {
                FlatFileParseException ffpe = (FlatFileParseException) e;
                StringBuilder errorMessage = new StringBuilder();
                errorMessage.append("An error occured while processing the "
                        + ffpe.getLineNumber()
                        + " line of the file. Below was the faulty " + "input.\n");
                errorMessage.append(ffpe.getInput() + "\n" + ffpe.getCause().getMessage() );
            } else {
                logger.error("An error has occured", e);
    Hope this help U.



    • #3

      Thanks for the response. I found this code snippet and was able to find the line and the error message. But this is not giving me the field wise error.

      [06/15/12 12:43:19.509 ERROR] An error occuerd while processing the 2 line of the file. Below was the faulty input.
      Unparseable number: ( in thread "main"

      Here the 4th field should be number, as it has an extra unwanted character it is failing. But I am not able to trap that the 4th field is having problem.