unpack error thanks for happy!

79 views
Skip to first unread message

toy...@gmail.com

unread,
Dec 22, 2008, 1:07:19 AM12/22/08
to jPOS Users
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE isopackager SYSTEM "genericpackager.dtd">

<isopackager headerLength="9">
<isofield id="0" length="4" name="Message Type Indicator"
class="org.jpos.iso.IFA_NUMERIC" />
<isofield id="1" length="16" name="Bitmap"

class="org.jpos.iso.IFA_BITMAP" />
<isofield id="11" length="6" name="Systems trace audit number"
class="org.jpos.iso.IFA_NUMERIC" />

<isofield id="37" length="12" name="Retrieval reference number"
class="org.jpos.iso.IF_CHAR" />

<isofieldpackager id="60" name="Additional Data" length="4"
class="org.jpos.iso.IFA_LLLCHAR"
packager="org.jpos.iso.packager.GenericPackager" maxValidField="11"
emitBitmap="true" bitmapField="0" firstField="0" headerLength="1">
<isofield id="1" name="Generic Error" length="2"
class="org.jpos.iso.IFA_NUMERIC" />
<isofield id="2" name="Address Ver Rese" length="1"
class="org.jpos.iso.IFA_NUMERIC" />
<isofield id="3" name="Telecode Ver Res" length="1"
class="org.jpos.iso.IFA_NUMERIC" />
</isofieldpackager>

</isopackager>

by the follow program
m.set (new ISOField (0, "1800"));
m.set (new ISOField (11, "101"));
m.set (new ISOField (37, "a"));
m.set (new ISOField (60, "1234"));
System.out.println(ISOUtil.dumpString(b));

resule is : 18000020000008000010000101a 0041234

but when i try to unpack error happen:
org.jpos.iso.ISOException: field packager '24' is null
at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:230)
at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:342)

and when

GenericPackager p = new GenericPackager("base1.xml");
InputStream in = new FileInputStream(visamsg.DAT");
int nbytes = in.available();
// Read in input file and strip any training white space
byte[] hexbytes = new byte[nbytes];
in.read(hexbytes, 0, nbytes);
while (Character.isWhitespace((char) hexbytes[nbytes - 1]))
nbytes--;
// Convert it to a byte array
byte b[] = ISOUtil.hex2byte(hexbytes, 0, nbytes / 2);
// And upack it into an ISOMsg
ISOMsg msg = new ISOMsg();
msg.setPackager(p);
msg.unpack(b);
error is:
java.lang.ArrayIndexOutOfBoundsException: 24
at org.jpos.iso.ISOUtil.hex2BitSet(ISOUtil.java:576)
at org.jpos.iso.IFA_BITMAP.unpack(IFA_BITMAP.java:68)
at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:214)
at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:342)
at examples.genericpackager.Test.main(Test.java:51)

how can i do to parse :18000020000008000010000101a 0041234

thanks!

Mark Salter

unread,
Dec 22, 2008, 4:39:46 AM12/22/08
to jpos-...@googlegroups.com
What on earth are you trying to do?

8)


toy...@gmail.com wrote:
> by the follow program
> m.set (new ISOField (0, "1800"));
> m.set (new ISOField (11, "101"));
> m.set (new ISOField (37, "a"));
> m.set (new ISOField (60, "1234"));
> System.out.println(ISOUtil.dumpString(b));
>
> resule is : 18000020000008000010000101a 0041234
>
> but when i try to unpack error happen:
> org.jpos.iso.ISOException: field packager '24' is null
> at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:230)
> at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:342)

What are you trying to unpack?
The result of the pack or something else?
From the code given below, can I assume you are also converting the
String into a byte array using ISOUtil.hex2byte and then the unpack of
the byte[] is failing?

If so, I would expect that as you have damaged the message entirely!

>
> and when
>
> GenericPackager p = new GenericPackager("base1.xml");
> InputStream in = new FileInputStream(visamsg.DAT");
> int nbytes = in.available();
> // Read in input file and strip any training white space
> byte[] hexbytes = new byte[nbytes];
> in.read(hexbytes, 0, nbytes);
> while (Character.isWhitespace((char) hexbytes[nbytes - 1]))
> nbytes--;

You should not throw anything away, spaces have just as much right to be
at the end of a message as any other character. You should take care to
preserve the whole message and not add (spaces) or take anything away.


> // Convert it to a byte array
> byte b[] = ISOUtil.hex2byte(hexbytes, 0, nbytes / 2);

Why do you want to do this conversion? Unless you are saving the
character message in a hex format, this breaks it.

You are failing to distinguish between character and hex and getting
yourself very confused. Take a deep breath and check what you are
trying to do please?

> // And upack it into an ISOMsg
> ISOMsg msg = new ISOMsg();
> msg.setPackager(p);
> msg.unpack(b);
> error is:
> java.lang.ArrayIndexOutOfBoundsException: 24
> at org.jpos.iso.ISOUtil.hex2BitSet(ISOUtil.java:576)
> at org.jpos.iso.IFA_BITMAP.unpack(IFA_BITMAP.java:68)
> at org.jpos.iso.ISOBasePackager.unpack(ISOBasePackager.java:214)
> at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:342)
> at examples.genericpackager.Test.main(Test.java:51)
>
> how can i do to parse :18000020000008000010000101a 0041234

msg.unpack("18000020000008000010000101a 0041234".getBytes());

might do what you need, but I am not certain, as it is not obvious to me
what you are trying to achieve.

--
Mark

chhil

unread,
Dec 22, 2008, 4:40:27 AM12/22/08
to jpos-...@googlegroups.com
You have a header of size 9 setup in your packager.
Set the header and "this" problem will go away.

Mark Salter

unread,
Dec 22, 2008, 4:44:21 AM12/22/08
to jpos-...@googlegroups.com
chhil wrote:
> You have a header of size 9 setup in your packager.Set the header and "this"
> problem will go away.
I missed the header completely, but think that will only take effect at
the Channel level?

I do think unnecessary hex conversions are causing the problems.

--
Mark

chhil

unread,
Dec 22, 2008, 4:48:30 AM12/22/08
to jpos-...@googlegroups.com
Ya..I should have been more specific about "this" ;)... it will fix the ISOException

> but when i try to unpack error happen:
> org.jpos.iso.ISOException: field packager '24' is null

-chhil

chhil

unread,
Dec 22, 2008, 5:30:53 AM12/22/08
to jpos-...@googlegroups.com
Oops ... I did it again ;)
field packager '24 is due to the was field 60 (the one with a bitmap is being used).
.ArrayIndexOutOfBoundsException:Is due to the header.

-chhil

Alejandro Revilla

unread,
Dec 22, 2008, 9:53:19 AM12/22/08
to jpos-...@googlegroups.com
>
> I missed the header completely, but think that will only take effect at
> the Channel level?
>
We have this support for headers at the packager level too, I think
using headerLength="9" is looking for trouble here.

Reply all
Reply to author
Forward
0 new messages