I have removed the leading dots from the OIDs, so
List<VariableBinding> varbinds = List.of(
new VariableBinding(new OID("1.3.6.1.2.1.1.5.0"), new OctetString("hostname")),
new VariableBinding(new OID("1.0.8802.1.1.1.1.2.1.0"), new Gauge32(1)));
oos.writeObject(varbinds);
Testing the behavior:
snmpgetnext -v 2c -c public 127.0.0.1 1.0.8802
SNMPv2-MIB::sysName.0 = STRING: hostname
2024-01-29 21:39:58.690 DEBUG transport.DefaultUdpTransportMapping(59) [DefaultUDPTransportMapping_0.0.0.0/161]: Received message from /127.0.0.1/59926 with length 36: 30:22:02:01:01:04:06:70:75:62:6c:69:63:a1:15:02:02:7e:bf:02:01:00:02:01:00:30:09:30:07:06:03:28:c4:62:05:00
2024-01-29 21:39:58.690 DEBUG snmp4j.Snmp(59) [DefaultUDPTransportMapping_0.0.0.0/161]: Fire process PDU event: CommandResponderEvent[securityModel=2, securityLevel=1, maxSizeResponsePDU=65512, pduHandle=PduHandle[32447], stateReference=StateReference[msgID=0,pduHandle=PduHandle[32447],securityEngineID=null,securityModel=null,securityName=public,securityLevel=1,contextEngineID=null,contextName=null,retryMsgIDs=null], pdu=GETNEXT[requestID=32447, errorStatus=Success(0), errorIndex=0, VBS[1.0.8802 = Null]], messageProcessingModel=1, securityName=public, processed=false, peerAddress=127.0.0.1/59926, transportMapping=org.snmp4j.transport.DefaultUdpTransportMapping@78f5c518, tmStateReference=TransportStateReference[transport=org.snmp4j.transport.DefaultUdpTransportMapping@78f5c518, address=0.0.0.0/161, securityName=null, requestedSecurityLevel=undefined, transportSecurityLevel=undefined, sameSecurity=false, sessionID=java.net.DatagramSocket@d3d3969, target=null]]
2024-01-29 21:39:58.690 DEBUG snmp.SnmpCommunityMIB(59) [DefaultUDPTransportMapping_0.0.0.0/161]: Looking up coexistence info for 'public'
2024-01-29 21:39:58.690 DEBUG snmp.SnmpCommunityMIB(59) [DefaultUDPTransportMapping_0.0.0.0/161]: Found coexistence info for 'public'=CoexistenceInfo[securityName=cpublic,contextEngineID=80:00:13:70:01:64:40:65:11:04:63:06:50,contextName=,transportTag=]
2024-01-29 21:39:58.690 DEBUG snmp.SnmpCommunityMIB(59) [DefaultUDPTransportMapping_0.0.0.0/161]: Address 127.0.0.1/59926 passes filter, because source address filtering is disabled
2024-01-29 21:39:58.690 DEBUG request.SnmpRequest(59) [RequestPool.0]: Limiting GETBULK maxRepetitions received as 0 to 0
2024-01-29 21:39:58.690 DEBUG snmp.VacmMIB(59) [RequestPool.0]: Found group name 'v1v2group' for secName 'cpublic' and secModel 2
2024-01-29 21:39:58.690 DEBUG snmp.VacmMIB(59) [RequestPool.0]: Got views [DefaultMOMutableRow2PC[index=9.118.49.118.50.103.114.111.117.112.0.0.1,values=[1, fullReadView, fullWriteView, fullNotifyView, 3, 1]] for group name 'v1v2group'
2024-01-29 21:39:58.690 DEBUG snmp.VacmMIB(59) [RequestPool.0]: Matching against access entry DefaultMOMutableRow2PC[index=9.118.49.118.50.103.114.111.117.112.0.0.1,values=[1, fullReadView, fullWriteView, fullNotifyView, 3, 1] with exactContextMatch=true, prefixMatch=false, matchSecModel=true and matchSecLevel=true
2024-01-29 21:39:58.690 DEBUG snmp.VacmMIB(59) [RequestPool.0]: Matching view found for group name 'v1v2group' is 'fullReadView'
2024-01-29 21:39:58.690 DEBUG request.SnmpRequest(59) [RequestPool.0]: Created subrequest 0 with scope org.snmp4j.agent.DefaultMOContextScope[context=,lowerBound=1.0.8802,lowerIncluded=false,upperBound=null,upperIncluded=false] from 1.0.8802 = Null
2024-01-29 21:39:58.690 DEBUG request.SnmpRequest(59) [RequestPool.0]: SnmpSubRequests initialized: [org.snmp4j.agent.request.SnmpRequest$SnmpSubRequest[scope=org.snmp4j.agent.DefaultMOContextScope[context=,lowerBound=1.0.8802,lowerIncluded=false,upperBound=null,upperIncluded=false],vb=1.0.8802 = Null,status=RequestStatus{processed=false, phaseComplete=false, errorStatus=0},query=null,index=0,targetMO=null,lookupEvent=null,maxRepetitionsWithLimit=0]]
2024-01-29 21:39:58.690 DEBUG snmp.VacmMIB(59) [RequestPool.0]: Access allowed for view 'fullReadView' by subtree 1.3 for OID 1.3.6.1.2.1.1.5.0 and mask
2024-01-29 21:39:58.690 DEBUG agent.CommandProcessor(59) [RequestPool.0]: Processing NEXT query org.snmp4j.agent.CommandProcessor$VACMQuery[]=1.0.8802< x <null[viewName=fullReadView] with StaticMOGroup[root=1.3.6.1.2.1.1.5,vbs={1.3.6.1.2.1.1.5.0=hostname}] sub-request with index 0
2024-01-29 21:39:58.690 DEBUG transport.DefaultUdpTransportMapping(59) [RequestPool.0]: Sending message to 127.0.0.1/59926 from 0.0.0.0/161 with length 49: 30:2f:02:01:01:04:06:70:75:62:6c:69:63:a2:22:02:02:7e:bf:02:01:00:02:01:00:30:16:30:14:06:08:2b:06:01:02:01:01:05:00:04:08:68:6f:73:74:6e:61:6d:65
2024-01-29 21:39:58.690 DEBUG transport.DefaultUdpTransportMapping(59) [RequestPool.0]: Sending packet to 127.0.0.1/59926