JPOS EE NacChannel config

491 views
Skip to first unread message

edmf1

unread,
Sep 10, 2009, 3:39:25 AM9/10/09
to jPOS Users
Hi all,

By reading through the forums I have successfully created a test
system in java that uses the NacChannel.

Now im trying to set it up using JPOS EE. Has anyone got a sample code
on how to set it up? This is the java code i used:

NACChannel channel = new NACChannel("192.168.7.100", 10000,
new ISO87BPackager(), new byte[5]);

jposLogger.addListener(new SimpleLogListener(System.out));

((LogSource) channel).setLogger(jposLogger, "test-channel");

channel.accept(new ServerSocket(10000));

ISOMsg r = channel.receive();

I have tested it with a Hypercom T4220 and it can successfully connect
and receive the message.

However, when i tried it on JPOS EE using this test config copied from
the sample serversimulator:

<?xml version="1.0" ?>
<server class="org.jpos.q2.iso.QServer" logger="Q2"
name="simulator_test">
<attr name="port" type="java.lang.Integer">10000</attr>
<channel class="org.jpos.iso.channel.NACChannel"
logger="Q2" packager="org.jpos.iso.packager.ISO87BPackager">
</channel>
<request-listener class="org.jpos.bsh.BSHRequestListener"
logger="Q2">
<property name="source" value="cfg/serversimulator.bsh" />
</request-listener>
</server>

Im getting exception errors:

[java] <log realm="simulator_test.server.session/192.168.7.220"
at="Thu Sep 10 15:34:27 PHT 2009.701">
[java] <session-start/>
[java] </log>
[java] error unpacking field 43
[java] org.jpos.iso.ISOException: org.jpos.iso.IF_CHAR: Problem
unpacking field 43 (java.lang.StringIndexOutOfBoundsException: String
index out of range: 75)
[java] at org.jpos.iso.ISOStringFieldPackager.unpack
(ISOStringFieldPackager.java:178)
[java] at org.jpos.iso.ISOBasePackager.unpack
(ISOBasePackager.java:233)
[java] at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:344)
[java] at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:853)
[java] at org.jpos.iso.BaseChannel.receive(BaseChannel.java:624)
[java] at org.jpos.iso.ISOServer$Session.run(ISOServer.java:146)
[java] at org.jpos.util.ThreadPool$PooledThread.run
(ThreadPool.java:74)
[java] Nested:java.lang.StringIndexOutOfBoundsException: String
index out of range: 75
[java] at java.lang.String.checkBounds(String.java:372)
[java] at java.lang.String.<init>(String.java:404)
[java] at org.jpos.iso.LiteralInterpreter.uninterpret
(LiteralInterpreter.java:51)
[java] at org.jpos.iso.ISOStringFieldPackager.unpack
(ISOStringFieldPackager.java:173)
[java] at org.jpos.iso.ISOBasePackager.unpack
(ISOBasePackager.java:233)
[java] at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:344)
[java] at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:853)
[java] at org.jpos.iso.BaseChannel.receive(BaseChannel.java:624)
[java] at org.jpos.iso.ISOServer$Session.run(ISOServer.java:146)
[java] at org.jpos.util.ThreadPool$PooledThread.run
(ThreadPool.java:74)
[java] <log realm="channel/192.168.7.220:11446" at="Thu Sep 10
15:34:27 PHT 2009.744">
[java] <receive>
[java] <iso-exception>
[java] org.jpos.iso.IF_CHAR: Problem unpacking field 43
[java] <nested-exception>
[java] java.lang.StringIndexOutOfBoundsException: String
index out of range: 75
[java] at java.lang.String.checkBounds(String.java:372)
[java] at java.lang.String.<init>(String.java:404)
[java] at org.jpos.iso.LiteralInterpreter.uninterpret
(LiteralInterpreter.java:51)
[java] at org.jpos.iso.ISOStringFieldPackager.unpack
(ISOStringFieldPackager.java:173)
[java] at org.jpos.iso.ISOBasePackager.unpack
(ISOBasePackager.java:233)
[java] at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:344)
[java] at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:853)
[java] at org.jpos.iso.BaseChannel.receive(BaseChannel.java:624)
[java] at org.jpos.iso.ISOServer$Session.run(ISOServer.java:146)
[java] at org.jpos.util.ThreadPool$PooledThread.run
(ThreadPool.java:74)
[java] </nested-exception>
[java] org.jpos.iso.ISOException: org.jpos.iso.IF_CHAR:
Problem unpacking field 43 (java.lang.StringIndexOutOfBoundsException:
String index out of range: 75)
[java] at org.jpos.iso.ISOStringFieldPackager.unpack
(ISOStringFieldPackager.java:178)
[java] at org.jpos.iso.ISOBasePackager.unpack
(ISOBasePackager.java:233)
[java] at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:344)
[java] at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:853)
[java] at org.jpos.iso.BaseChannel.receive(BaseChannel.java:624)
[java] at org.jpos.iso.ISOServer$Session.run(ISOServer.java:146)
[java] at org.jpos.util.ThreadPool$PooledThread.run
(ThreadPool.java:74)
[java] Nested:java.lang.StringIndexOutOfBoundsException: String
index out of range: 75
[java] at java.lang.String.checkBounds(String.java:372)
[java] at java.lang.String.<init>(String.java:404)
[java] at org.jpos.iso.LiteralInterpreter.uninterpret
(LiteralInterpreter.java:51)
[java] at org.jpos.iso.ISOStringFieldPackager.unpack
(ISOStringFieldPackager.java:173)
[java] at org.jpos.iso.ISOBasePackager.unpack
(ISOBasePackager.java:233)
[java] at org.jpos.iso.ISOMsg.unpack(ISOMsg.java:344)
[java] at org.jpos.iso.BaseChannel.unpack(BaseChannel.java:853)
[java] at org.jpos.iso.BaseChannel.receive(BaseChannel.java:624)
[java] at org.jpos.iso.ISOServer$Session.run(ISOServer.java:146)
[java] at org.jpos.util.ThreadPool$PooledThread.run
(ThreadPool.java:74)
[java] </iso-exception>
[java] --- data ---
[java] 0000 60 00 02 00 00 04 00 70 24 05 80 00 C0 00 04
16 `......p$.......
[java] 0010 43 86 16 00 00 00 22 28 00 00 00 00 00 00 04 58
C....."(.......X
[java] 0020 00 00 00 03 13 12 00 22 00 02 00 31 32 33 34
35 ......."...12345
[java] 0030 36 37 38 30 30 30 30 30 30 30 30 30 31 32 33 34
6780000000001234
[java] 0040 35 36 00 06 30 31 33 39 35 31
56..013951
[java]
[java] </receive>
[java] </log>

I would want to believe my mistake was just not passing in a value for
TPDU. Frankly im quite stuck on how to pass a byte[] property to the
channel in xml. :(

Victor Salaman

unread,
Sep 10, 2009, 4:19:50 AM9/10/09
to jpos-...@googlegroups.com
Hi:

Make your channel element have a header attribute as in:

<channel class="org.jpos.iso.channel.NACChannel" logger="Q2" packager="org.jpos.iso.packager.ISO87BPackager" header="00000"></channel>

The 00000's are used here as a length placeholder... they will be overriden upon reading by the correct header bytes.
When you reply, make sure to set the desired header in the ISOMsg so the channel can use that header instead of the 00000s....

/V

Mark Salter

unread,
Sep 10, 2009, 4:23:33 AM9/10/09
to jpos-...@googlegroups.com
edmf1 wrote:
> Hi all,
>
> By reading through the forums I have successfully created a test
> system in java that uses the NacChannel.
Halfway there then 8).

Do you also have the Programmers guide? May I suggest it would be worth
you getting that too?

>
> Now im trying to set it up using JPOS EE. Has anyone got a sample code
> on how to set it up?

This is just where the guide would come in handy.


[log snip]

Please take care when testing that you use test card numbers, the log
provided contains the card details...

... I'm sure you will be, I just thought I would mention it in case.

>
> I would want to believe my mistake was just not passing in a value for
> TPDU. Frankly im quite stuck on how to pass a byte[] property to the
> channel in xml. :(
>

Seems likely, not knowing about the header will cause the wrong parts of
the stream to be treated as the bitmap etc...

...The channel does not need a byte[] but a hint of the header/TPDU
length expected...

... so try adding a header attribute to the channel:-

<?xml version="1.0" ?>
<server class="org.jpos.q2.iso.QServer" logger="Q2"
name="simulator_test">
<attr name="port" type="java.lang.Integer">10000</attr>
<channel class="org.jpos.iso.channel.NACChannel"
logger="Q2" packager="org.jpos.iso.packager.ISO87BPackager"

header="12345" >


</channel>
<request-listener class="org.jpos.bsh.BSHRequestListener"
logger="Q2">
<property name="source" value="cfg/serversimulator.bsh" />
</request-listener>
</server>

As indicated in section 9.1 of the guide, this will set the stage so
that the channel absorbs 5 bytes from the stream as the header of the
incoming stream.

--
Mark

Mark Salter

unread,
Sep 10, 2009, 4:24:31 AM9/10/09
to jpos-...@googlegroups.com
Victor Salaman wrote:

> When you reply, make sure to set the desired header in the ISOMsg so the
> channel can use that header instead of the 00000s....

Good point Victor.

--
Mark

edmf1

unread,
Sep 10, 2009, 4:34:55 AM9/10/09
to jPOS Users
Thanks! It worked. i actually received "6000020000" for a header. so i
set it to header="0000000000" instead of "00000".

Mark Salter

unread,
Sep 10, 2009, 4:42:04 AM9/10/09
to jpos-...@googlegroups.com
edmf1 wrote:
> Thanks! It worked. i actually received "6000020000" for a header. so i
> set it to header="0000000000" instead of "00000".

Ah yes, because NACChannel treats the header as a String representing
bcd, so each two characters represents one byte.

Glad we could help.


--
Mark

edmf1

unread,
Sep 10, 2009, 5:43:39 AM9/10/09
to jPOS Users
hi Mark,

yes we did bought the programmers guide. Though i seem to learn more
stuff in the forums than the guide.

Mark Salter

unread,
Sep 10, 2009, 5:55:54 AM9/10/09
to jpos-...@googlegroups.com
edmf1 wrote:

> yes we did bought the programmers guide.

Great.

> Though i seem to learn more
> stuff in the forums than the guide.

A positive reflection on the jPos community 8).

--
Mark

Reply all
Reply to author
Forward
0 new messages