Re: [jpos-users] Error: Problem unpacking field

瀏覽次數:1,378 次
跳到第一則未讀訊息

Alejandro Revilla

未讀,
2012年6月26日 清晨7:19:082012/6/26
收件者:jpos-...@googlegroups.com
I'd start by adding a logger to your packager:

 Logger logger = new Logger();
 logger.addListener (new SimpleLogListener(System.out));
 ((LogSource)p).setLogger(logger, "debug");

Then run again and see if fields prior to 59 get properly unpacked.
 
--
@apr



On Tue, Jun 26, 2012 at 7:51 AM, RohanGJ <rohan.ja...@mobilewaretech.com> wrote:
Hi,
     I recently started using JPOS. I am getting Following error after running my test class.

org.jpos.iso.ISOException: org.jpos.iso.IFA_LLLCHAR: Problem unpacking field 59 (java.lang.RuntimeException: Required 2157 but just got 75 bytes) unpacking field=59, consumed=155
at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:261)
at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:416)
at com.mwt.purchaseAuth.jpos.ISOUnpacker.main(ISOUnpacker.java:17)

My main method in  test class is - 

public static void main(String[] args) {
String msg = "0200B238800128E080180000000010000000000000000000020000012812545522348718255201280128014314181300002003801=1306126422000000281222348740030239HARKOP PETROLEUCHARKOP PETROLEUM HARKOP PETROLMHRIN356012SARCSARC+0000134181PROD0000Z06418130";
try {
ISOMsg m = new ISOMsg();
ISOPackager p = new GenericPackager ("resources\\iso8583PurchaseAuth.xml");
m.setPackager (p);
m.unpack (msg.getBytes());
System.out.println(m);
} catch (ISOException e) {
e.printStackTrace();
}
}


and XML File is - 

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE isopackager PUBLIC
        "-//jPOS/jPOS Generic Packager DTD 1.0//EN"

<!-- ISO 8583:1993 (ASCII) field descriptions for GenericPackager -->

<isopackager>
  <isofield
      id="0"
      length="4"
      name="Message Type Indicator"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="1"
      length="64"
      name="Bitmap"
      class="org.jpos.iso.IFB_BITMAP"/>
  <isofield
      id="2"
      length="19"
      name="Primary Account number"
      class="org.jpos.iso.IFA_LLNUM"/>
  <isofield
      id="3"
      length="6"
      name="Processing Code"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="4"
      length="12"
      name="Amount, Transaction"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="5"
      length="12"
      name="Amount, Reconciliation"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="6"
      length="12"
      name="Amount, Cardholder billing"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="7"
      length="10"
      name="Date and time, transmission"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="8"
      length="8"
      name="Amount, Cardholder billing fee"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="9"
      length="8"
      name="Conversion rate, Reconciliation"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="10"
      length="8"
      name="Conversion rate, Cardholder billing"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="11"
      length="6"
      name="Systems trace audit number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="12"
      length="6"
      name="Date and time, Local transaction"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="13"
      length="4"
      name="Date, Effective"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="14"
      length="4"
      name="Date, Expiration"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="15"
      length="4"
      name="Date, Settlement"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="16"
      length="4"
      name="Date, Conversion"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="17"
      length="4"
      name="Date, Capture"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="18"
      length="4"
      name="Merchant type"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="19"
      length="3"
      name="Country code, Acquiring institution"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="20"
      length="3"
      name="Country code, Primary account number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="21"
      length="3"
      name="Country code, Forwarding institution"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="22"
      length="3"
      name="Point of service data code"
      class="org.jpos.iso.IF_CHAR"/>
  <isofield
      id="23"
      length="3"
      name="Card sequence number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="24"
      length="3"
      name="Function code"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="25"
      length="2"
      name="Message reason code"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="26"
      length="2"
      name="Card acceptor business code"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="27"
      length="1"
      name="Approval code length"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="28"
      length="8"
      name="Date, Reconciliation"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="29"
      length="8"
      name="Reconciliation indicator"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="30"
      length="8"
      name="Amounts, original"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="31"
      length="8"
      name="Acquirer reference data"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="32"
      length="11"
      name="Acquirer institution identification code"
      class="org.jpos.iso.IFA_LLNUM"/>
  <isofield
      id="33"
      length="11"
      name="Forwarding institution identification code"
      class="org.jpos.iso.IFA_LLNUM"/>
  <isofield
      id="34"
      length="28"
      name="Primary account number, extended"
      class="org.jpos.iso.IFA_LLNUM"/>
  <isofield
      id="35"
      length="37"
      name="Track 2 data"
      class="org.jpos.iso.IFA_LLBNUM"/>
  <isofield
      id="36"
      length="104"
      name="Track 3 data"
      class="org.jpos.iso.IFA_LLBNUM"/>
  <isofield
      id="37"
      length="12"
      name="Retrieval reference number"
      class="org.jpos.iso.IF_CHAR"/>
  <isofield
      id="38"
      length="6"
      name="Approval code"
      class="org.jpos.iso.IF_CHAR"/>
  <isofield
      id="39"
      length="2"
      name="Action code"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="40"
      length="3"
      name="Service code"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="41"
      length="8"
      name="Card acceptor terminal identification"
      class="org.jpos.iso.IF_CHAR"/>
  <isofield
      id="42"
      length="15"
      name="Card acceptor identification code"
      class="org.jpos.iso.IF_CHAR"/>
  <isofield
      id="43"
      length="40"
      name="Card acceptor name/location"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="44"
      length="25"
      name="Additional response data"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="45"
      length="76"
      name="Track 1 data"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="46"
      length="999"
      name="Additional data - ISO"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="47"
      length="999"
      name="Additional data - national"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="48"
      length="999"
      name="Additional data - private"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="49"
      length="3"
      name="Currency code, Transaction"
      class="org.jpos.iso.IF_CHAR"/>
  <isofield
      id="50"
      length="3"
      name="Currency code, Reconciliation"
      class="org.jpos.iso.IF_CHAR"/>
  <isofield
      id="51"
      length="3"
      name="Currency code, Cardholder billing"
      class="org.jpos.iso.IF_CHAR"/>
  <isofield
      id="52"
      length="16"
      name="Personal identification number [PIN] data"
      class="org.jpos.iso.IFA_BINARY"/>
  <isofield
      id="53"
      length="18"
      name="Security related control information"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="54"
      length="120"
      name="Amounts, additional"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="55"
      length="999"
      name="Reserved ISO"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="56"
      length="999"
      name="Reserved ISO"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="57"
      length="999"
      name="Reserved National"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="58"
      length="999"
      name="Reserved National"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="59"
      length="999"
      name="Reserved for national use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="60"
      length="7"
      name="Advice/reason code (private reserved)"
      class="org.jpos.iso.IFB_LLCHAR"/>
  <isofield
      id="61"
      length="999"
      name="Reserved for private use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="62"
      length="999"
      name="Reserved for private use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="63"
      length="999"
      name="Reserved for private use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="64"
      length="16"
      name="Message authentication code field"
      class="org.jpos.iso.IFA_BINARY"/>
  <isofield
      id="65"
      length="64"
      name="bitmap tertiary"
      class="org.jpos.iso.IFB_BITMAP"/>
  <isofield
      id="66"
      length="1"
      name="Settlement code"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="67"
      length="2"
      name="Extended payment data"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="68"
      length="3"
      name="Country code, receiving institution"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="69"
      length="3"
      name="Country code, settlement institution"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="70"
      length="3"
      name="Country code, authorizing agent Inst."
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="71"
      length="4"
      name="Message number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="72"
      length="999"
      name="Data record"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="73"
      length="6"
      name="Date, action"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="74"
      length="10"
      name="Credits, number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="75"
      length="10"
      name="Credits, reversal number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="76"
      length="10"
      name="Debits, number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="77"
      length="10"
      name="Debits, reversal number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="78"
      length="10"
      name="Transfer, number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="79"
      length="10"
      name="Transfer, reversal number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="80"
      length="10"
      name="Inquiries, number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="81"
      length="10"
      name="Authorizations, number"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="82"
      length="12"
      name="Credits, processing fee amount"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="83"
      length="12"
      name="Credits, transaction fee amount"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="84"
      length="12"
      name="Debits, processing fee amount"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="85"
      length="12"
      name="Debits, transaction fee amount"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="86"
      length="15"
      name="Credits, amount"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="87"
      length="15"
      name="Credits, reversal amount"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="88"
      length="15"
      name="Debits, amount"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="89"
      length="15"
      name="Debits, reversal amount"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="90"
      length="42"
      name="Original data elements"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="91"
      length="1"
      name="File update code"
      class="org.jpos.iso.IF_CHAR"/>
  <isofield
      id="92"
      length="2"
      name="File security code"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="93"
      length="5"
      name="Response indicator"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="94"
      length="7"
      name="Service indicator"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="95"
      length="42"
      name="Replacement amounts"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="96"
      length="8"
      name="Message security code"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="97"
      length="16"
      name="Amount, Net reconciliation"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="98"
      length="25"
      name="Payee"
      class="org.jpos.iso.IF_CHAR"/>
  <isofield
      id="99"
      length="11"
      name="Settlement institution Id code"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="100"
      length="11"
      name="Receiving institution Id code"
      class="org.jpos.iso.IFA_LLNUM"/>
  <isofield
      id="101"
      length="17"
      name="File name"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="102"
      length="28"
      name="Account identification 1"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="103"
      length="28"
      name="Account identification 2"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="104"
      length="100"
      name="Transaction description"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="105"
      length="999"
      name="Reserved for ISO use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="106"
      length="999"
      name="Reserved for ISO use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="107"
      length="999"
      name="Reserved for ISO use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="108"
      length="999"
      name="Reserved for ISO use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="109"
      length="999"
      name="Reserved for ISO use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="110"
      length="999"
      name="Reserved for ISO use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="111"
      length="999"
      name="Reserved for ISO use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="112"
      length="999"
      name="Reserved for ISO use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="113"
      length="11"
      name="Authorizing agent institution id code"
      class="org.jpos.iso.IFA_LLNUM"/>
  <isofield
      id="114"
      length="999"
      name="Reserved for national use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="115"
      length="999"
      name="Reserved for national use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="116"
      length="999"
      name="Reserved for national use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="117"
      length="999"
      name="Reserved for national use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="118"
      length="999"
      name="Reserved for national use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="119"
      length="999"
      name="Reserved for national use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="120"
      length="999"
      name="Reserved for private use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="121"
      length="999"
      name="Reserved for private use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="122"
      length="999"
      name="Reserved for private use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="123"
      length="999"
      name="Reserved for private use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="124"
      length="255"
      name="Info Text"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="125"
      length="50"
      name="Network management information"
      class="org.jpos.iso.IFA_LLCHAR"/>
  <isofield
      id="126"
      length="6"
      name="Issuer trace id"
      class="org.jpos.iso.IF_CHAR"/>
  <isofield
      id="127"
      length="999"
      name="Reserved for private use"
      class="org.jpos.iso.IFA_LLLCHAR"/>
  <isofield
      id="128"
      length="16"
      name="Message Authentication code"
      class="org.jpos.iso.IFA_BINARY"/>
</isopackager>


I know I am missing something here but don't know what is going wrong with field 59. 
I am giving complete xml file because I this there might be something wrong with fields other than 59th.
Any help would be appreciated. 

--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage.
Please support jPOS, contact: sa...@jpos.org
 
You received this message because you are subscribed to the "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users

Mark Salter

未讀,
2012年6月26日 清晨7:22:052012/6/26
收件者:jpos-...@googlegroups.com
On 26/06/2012 11:51, RohanGJ wrote:
> *Hi,*
> * I recently started using JPOS. I am getting Following error after
> running my test class.*
>
> org.jpos.iso.ISOException: org.jpos.iso.IFA_LLLCHAR: Problem unpacking
> field 59 (java.lang.RuntimeException: Required 2157 but just got 75
> bytes) unpacking field=59, consumed=155
The field length looks odd, so it is likely to be as issue in the lead
up to the field that tries to run off the end.

There is likely a mismatch between packager and message.

I suggest you add a Logger to you Packager:-

.
.
Logger logger = new Logger();
logger.addListener (new SimpleLogListener (System.out));
p.setLogger(logger)
.
.

then you will see on your stdout (or existing log if you have a Logger
to reuse) what data is going into which fields and thus what is causing
the misalignment in your test - bad data or bad packager.

--
Mark


Mark Salter

未讀,
2012年6月26日 清晨7:23:442012/6/26
收件者:jpos-...@googlegroups.com
On 26/06/2012 12:19, Alejandro Revilla wrote:
> ((LogSource)p).setLogger(logger, "debug");
Ah, beat me to it and got it correct too!

:-)

--
Mark


Alejandro Revilla

未讀,
2012年6月26日 上午8:05:122012/6/26
收件者:jpos-...@googlegroups.com
:) p was an ISOPackager, not a GenericPackager (which implements LogSource)

--
@apr




--
Mark


回覆所有人
回覆作者
轉寄
0 則新訊息