Search code examples
jpos

Problem unpacking field with jPOS for ISO8583


Newbie to jPOS and ISO. Tried parsing an ISO8583-1987 message with the jPOS library and got the below error. Please suggest how could it be debugged for more information.

    var isoMsg = new ISOMsg();
    isoMsg.setPackager(new ISO87APackagerBBitmap());
    isoMsg.unpack(payload);
Caused by: org.jpos.iso.ISOException: org.jpos.iso.IFA_LLLCHAR: Problem unpacking field 54 (org.jpos.iso.ISOException: Field length 797 too long. Max: 120) unpacking field=54, consumed=140
    at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:341)
    at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:479)

Solution

  • Add a logger and a log listener to the packager:

    Logger logger = new Logger();
    logger.addListener(new SimpleLogListener());
    ISOBasePackager packager = new ISO87APackagerBBitmap();
    packager.setLogger(logger, "packager");
    isoMsg.setPackager(packager);
    isoMsg.unpack(payload);
    
    

    There you will be able to see from which field the packager is unaligned. But since probably the packager will not suit your needs, I would use a GenericPackager and start modifying the fields that are not aligned. It's also important to check that every filed in your packager aligns with the spec of that payload.