# Java client read throws "Error Code -2: Unexpected batch key returned: null,,0"

**URL:** <https://discuss.aerospike.com/t/java-client-read-throws-error-code-2-unexpected-batch-key-returned-null-0/9218>\
**Category:** Java Client\
**Tags:** java, error\
**Created:** [February 14, 2022, 8:30pm UTC](https://discuss.aerospike.com/t/java-client-read-throws-error-code-2-unexpected-batch-key-returned-null-0/9218 "2022-02-14T20:30:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shan.p](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/shan.p/32/1990_2.png) [@shan.p](https://discuss.aerospike.com/u/shan.p)\
**Post date:** [February 14, 2022, 8:30pm UTC](https://discuss.aerospike.com/t/java-client-read-throws-error-code-2-unexpected-batch-key-returned-null-0/9218/1 "2022-02-14T20:30:47Z")

</div>

I am seeing an Aerospike Java client read error when reading a record from Aerospike Enterprise server.

Aerospike Java client: 4.0.4 (I agree this is an old version. I will upgrade to later version, but I still want to understand this error, since there is a topic on how the clients are backward compatible - [Java client and server compatibility matrix](https://discuss.aerospike.com/t/java-client-and-server-compatibility-matrix/4977)).

Aerospike server: Enterprise Edition 5.7

The record I write into the server has the key - `"tl:null:t034001118454:4d7dcd9166211b445fc6890aad2b28192d7b42f8"`.

I verified that the record is added to the server (it is a fresh installation, so there is only one record).

```auto
aql> set output json
OUTPUT = JSON
aql> set record_print_metadata true
RECORD_PRINT_METADATA = true
aql> select * from tl;

[
    [
        {
          "edigest": "TX3NkWYhG0RfxokKrSsoGS17Qvg=",
          "ttl": 172395,
          "gen": 5,
          "bins": {
            "": "78 9C 63 64 60 60 60 34 36 D1 33 30 D8 A8 6B 68 68 A1 67 62 BA A5 29 1D 2C 66 64 50 61 BA 01 C4 32 00 01 C3 78 30 B5 11 85 C3 C0 C0 74 18 A2 0E 00 F5 C5 0F 91"
          }
        }
    ],
    [
        {
          "Status": 0
        }
    ]
]

```

When I read the record with the Java client (same application, 4.0.4 version client), I get the following error:

```auto
2022-02-14 18:10:56.006	ERROR	com.cache.AerospikeService	Error Code -2: Unexpected batch key returned: null,,0
com.aerospike.client.AerospikeException$Parse: Error Code -2: Unexpected batch key returned: null,,0
	at com.aerospike.client.command.Batch$GetArrayCommand.parseRow(Batch.java:109)
	at com.aerospike.client.command.MultiCommand.parseGroup(MultiCommand.java:107)
	at com.aerospike.client.command.MultiCommand.parseResult(MultiCommand.java:64)
	at com.aerospike.client.command.SyncCommand.execute(SyncCommand.java:83)
	at com.aerospike.client.command.BatchExecutor.execute(BatchExecutor.java:51)
	at com.aerospike.client.AerospikeClient.get(AerospikeClient.java:1023)
	at com.cache.AerospikeService.find(AerospikeService.java:179)

```

What is the reason for this error? I verified the same key is used for the read and write operation.

---

<div class="post-metadata">

**Author:** ![meher](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/meher/32/1644_2.png) [@meher](https://discuss.aerospike.com/u/meher)\
**Post date:** [February 15, 2022, 5:40am UTC](https://discuss.aerospike.com/t/java-client-read-throws-error-code-2-unexpected-batch-key-returned-null-0/9218/2 "2022-02-15T05:40:32Z")

</div>

It should be because the server is not returning the digests anymore for batch transactions. So you would have explicitly configure the client as per the [5.7 server release notes](https://download.aerospike.com/download/server/notes.html#5.7.0.10):

“The configuration parameter [`batch-without-digests`](https://download.aerospike.com/docs/reference/configuration/index.html?show-removed=1#batch-without-digests), now defaults to true, is deprecated and will be removed in six months. Customers using clients older than a year (around the time of Server 4.9 which introduced [`batch-without-digests`](https://download.aerospike.com/docs/reference/configuration/index.html?show-removed=1#batch-without-digests)) will now have to explicitly set the [`batch-without-digests`](https://download.aerospike.com/docs/reference/configuration/index.html?show-removed=1#batch-without-digests) configuration item to false.”

---

<div class="post-metadata">

**Author:** ![shan.p](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/shan.p/32/1990_2.png) [@shan.p](https://discuss.aerospike.com/u/shan.p)\
**Post date:** [February 15, 2022, 8:08pm UTC](https://discuss.aerospike.com/t/java-client-read-throws-error-code-2-unexpected-batch-key-returned-null-0/9218/3 "2022-02-15T20:08:05Z")

</div>

@meher thanks for the reply. So even if I enable the configuration parameter [`batch-without-digests`](https://download.aerospike.com/docs/reference/configuration/index.html?show-removed=1#batch-without-digests), I still need to upgrade the Java client to 4.4.5, since this option only works with 4.4.5. Is that correct?

From the [docs](https://download.aerospike.com/docs/reference/configuration/index.html?show-removed=1#batch-without-digests):

**Note:** To use `batch-without-digests` , the minimum client versions required are as follows:

- Java client version 4.4.5

---

<div class="post-metadata">

**Author:** ![meher](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/meher/32/1644_2.png) [@meher](https://discuss.aerospike.com/u/meher)\
**Post date:** [February 16, 2022, 12:39am UTC](https://discuss.aerospike.com/t/java-client-read-throws-error-code-2-unexpected-batch-key-returned-null-0/9218/4 "2022-02-16T00:39:21Z")

</div>

Oh, yes, good catch. You would indeed have to upgrade the client.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/system/32/2274_2.png) [@system](https://discuss.aerospike.com/u/system)\
**Post date:** [May 11, 2022, 12:40am UTC](https://discuss.aerospike.com/t/java-client-read-throws-error-code-2-unexpected-batch-key-returned-null-0/9218/5 "2022-05-11T00:40:15Z")

</div>

This topic was automatically closed 84 days after the last reply. New replies are no longer allowed.
