Search code examples
javaxmliso8583jpos

Get NullPointerException when call pack() JPOS


i worked in ISO 8583. And i use JPOS to parse and unparse ISO message. But, when i parse the message, i get this following error :

java.lang.NullPointerException
    at org.jpos.iso.ISOBasePackager.pack(ISOBasePackager.java:94)
    at org.jpos.iso.ISOMsg.pack(ISOMsg.java:442)
    at com.sti.payment.postpaid.service.TransactionService.response(TransactionService.java:76)
    at com.sti.payment.postpaid.App.main(App.java:35)

The error point to :

byte [] bIsoMsg = isoMsg.pack();

Here is my code :

public void response(String responseMessage) throws Exception {
    // TODO Auto-generated method stub
    GenericPackager packager = new GenericPackager("de-payment-request.xml");

    // Buat ISO Messagenya
    ISOMsg isoMsg = new ISOMsg();
    isoMsg.setPackager(packager);
    isoMsg.setMTI("0210");
    isoMsg.set(1, "723A40010A818000");
    isoMsg.set(2, "162333444455556666");
    isoMsg.set(3, "380099");

    byte [] bIsoMsg = isoMsg.pack();
}

And here is my XML :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE isopackager SYSTEM "genericpackager.dtd">
<isopackager>
  <isofield
    id="1"
    length="64"
    name="BIT MAP"
    class="org.jpos.iso.IFA_BITMAP"
  />
  <isofield
    id="2"
    length="16"
    name="PRIMARY ACCOUNT NUMBER"
    class="org.jpos.iso.IFA_LLNUM"
  />
  <isofield
    id="3"
    length="6"
    name="PROCESSING CODE"
    class="org.jpos.iso.IFA_NUMERIC"
  />
</isopackager>

What i missed? Thank you very much.


Solution

  • Answer

    For now may be it is not the best and fit answer for my problem. Just exclude the ID 1 in your pack method. It works for me. Cause JPOS automatically add ID 1 and 2 for your message.