Problem with xbee-api written in Java

I have a USB interface board with XBee Pro Series 2 connected to my computer. X-CTU works well for the module, such as range test, neighbor discovery, etc.
Now I tried to control the module from my own program. After reading some references, I tried xbee-api written in Java.

I have set my XBee module to be API mode 2. Then I tried ApiAtTest example in the code, the simplest example.
Oops, I got the following error:

Stable Library

Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
[2010-04-19 17:43:42,865] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] Read base10=126,base16=0x7e,base2=01111110 from input stream
[2010-04-19 17:43:42,891] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.PacketStream] Read Length MSB byte, val is base10=0,base16=0x00,base2=00000000
[2010-04-19 17:43:42,892] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.PacketStream] Read Length LSB byte, val is base10=4,base16=0x04,base2=00000100
[2010-04-19 17:43:42,893] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.PacketStream] Read API ID byte, val is base10=8,base16=0x08,base2=00001000
[2010-04-19 17:43:42,893] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.PacketStream] Read Checksum byte, val is base10=1,base16=0x01,base2=00000001
[2010-04-19 17:43:42,896] [XBee Packet Parser Thread] [ERROR] [com.rapplogic.xbee.api.PacketStream] Failed due to exception. Returning ErrorResponse. bytes read: 0x00 0x04 0x08 0x01
at com.rapplogic.xbee.api.PacketStream.parsePacket(
at Source)
[2010-04-19 17:43:42,899] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] Read base10=77,base16=0x4d,base2=01001101 from input stream
[2010-04-19 17:43:42,899] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x4d, discarding
[2010-04-19 17:43:42,900] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] Read base10=89,base16=0x59,base2=01011001 from input stream
[2010-04-19 17:43:42,901] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x59, discarding
[2010-04-19 17:43:42,901] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] Read base10=80,base16=0x50,base2=01010000 from input stream
[2010-04-19 17:43:42,902] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] expected start byte but got this 0x50, discarding
Exception in thread “main” [2010-04-19 17:43:47,954] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] Packet parser thread was interrupted
[2010-04-19 17:43:47,955] [XBee Packet Parser Thread] [WARN] [com.rapplogic.xbee.api.XBeePacketParser] Packet parser thread is exiting
at com.rapplogic.xbee.api.XBee.sendSynchronous(
at com.rapplogic.xbee.api.XBee.sendAtCommand(
at com.rapplogic.xbee.examples.ApiAtTest.(
at com.rapplogic.xbee.examples.ApiAtTest.main(

I debugged the program slowly and carefully and found that the response I got is the AT command I sent.
I sent 0x7e 0x00 0x04 0x08 0x01 0x4d 0x59 0x50, the “MY” command API-packet. It is expected to get response of MY, such as “5767” got from X-CTU. However, I got 0x7e 0x00 0x04 0x08 0x01 0x4d 0x59 0x50 again. As 0x08 is the API-ID, it represents for AT Command. While there is no such kind of response, the error above happened.
I am very confusing about this now and don’t know how to forward. Wish someone can give me some suggestion. Thank you very much first.

I made more test to find what happened.
From X-CTU, I found that what I input will be output immediately.
This could be used to explain what happened to the program. I input “0x7e 0x00 0x04 0x08 0x01 0x4d 0x59 0x50” and I will get response as “0x7e 0x00 0x04 0x08 0x01 0x4d 0x59 0x50”.
This must be some problem in the configuration. Anyone who can tell me what’s wrong with my configuration?
Thank you.

Do you have an API type firmware on your XBee series 2? Can you talk to it from XCTU with the PC Settings “Enable API” box checked?

Thank you very much for you replay.
Yes. I can talk with it with X-CTU on windows.
I can also use a library xbee-python to communicate with it.
As you said, the problem is because of the firmware. From X-CTU, I didn’t see AP option in the firmware.
Furthermore, when I try to execute “ATAP 2”, I always get “ERROR”.
I would like to update the firmware. But I don’t know how to get a firmware with AP option for the “XBee Pro Series 2”.
Is any firmware is OK or I should find firmware for “XBee Pro Series 2”?

You’ll want to use one of the “API” firmware types. Here’s a link to the 2x64 ZB firmware zip:

Load this through XCTU > Modem Configuration > Download new versions > File > then point to the downloaded zip.