Error using TableUtils.getTable(). Data is returned ok but error occurs


I have an agent class with snmpv3 that implements the CommandResponder interface. I have a processPDU() method with my own implementation that responds correctly to OID petitions.

My problems arrives when I try using the method getTable() from TableUtils class. This is the answer that I receive from the agent. (this the list of events printed)

[org.snmp4j.util.TableEvent[index=,vbs=[ = 1, = 2, = 3, = 4],status=-2,exception=null,report=null], org.snmp4j.util.TableEvent[index=,vbs=[ = 1, = 2, = 3, = 4],status=-2,exception=null,report=null], org.snmp4j.util.TableEvent[index=,vbs=[ = 1, = 2, = 3, = 4],status=-2,exception=null,report=null], org.snmp4j.util.TableEvent[index=null,vbs=null,status=-2,exception=null,report=null]]

As you can see I get the correct values, but index is empty and status is -2.

Some more information. When I try to get the data without using the next code in the petitioner a Lexicon order error occurs.

The root cause of your issue is then agent you responding to your query with objects in wrong lexicographic order. That means, it returns the same or preceding objects while it should return succeeding objects. When command generator like TableUtils tries to browse a whole sub-tree, it would end in an endless loop. That is why this bug in the agent cannot be ignored and is fatal.

Hi, thanks for the answer.

Right now processPdu() receives the pdu and looks up the value of the object in a java map.
What should I do to answer the TableUtils.getTable() method correctly?
Is there an example to look at? I couldn´t find anything in the documentation.


How did you specify the column OIDs to be retrieved?
May be there is an error?

If the error is in the agent, you can’t fix it with the getTable call parameters.

I think I´m explaining myself wrong.

In my agent there is a Map<OID, String> where I store the values of the oids. When processPdu() is called the value of the requested oid (stored in the map) is returned via the answer pdu. For non tabular data this works ok.

I know this is wrong, but it worked well enough. The problem is answering to tables, my question is, how this tabular data should be stored so the agent can answer the tables oids correctly?

public synchronized void processPdu(CommandResponderEvent aEvent) {
    PDU pdu = aEvent.getPDU();
    if (pdu == null) {
    // PDU response construction
    for (int i = 0; i < pdu.size(); i++) {
        OID oid = pdu.get(i).getOid();
        String response = getResponse(oid); // gets value of the OID from the map
        pdu.set(i, new VariableBinding(oid, new OctetString(response)));

    StatusInformation statusInformation = new StatusInformation();
    StateReference stateRef = aEvent.getStateReference();
    try {
                aEvent.getSecurityModel(), aEvent.getSecurityName(), aEvent.getSecurityLevel(), pdu,
                aEvent.getMaxSizeResponsePDU(), stateRef, statusInformation);
    } catch (MessageException ex) {

To be able to process GETNEXT and GETBULK PDUs a lot of logic is needed and at least an OrderedMap. I doubt that you get something like this working correctly by implementing it yourself when doing it for the first time.

Why not using a SNMP agent framework like SNMP4J-Agent for that?