NotificationOriginatorImpl throws java.net.BindException

I am trying to run the sampleAgent that is shipped with Agent API. I am starting the process “-c udp:10.89.234.198/8000” as parameters. i am able to start the process but i see the following exception are coming when it tries sending a notification.
from the logs and code i see that it is trying to send the notification to “127.0.0.1/162”. i dont have any application runnign on that port and i dont see any configuration to customize this so thta i can send notifications to my custom ip addres. please help

exception is:

Sending message to 127.0.0.1/162 with length 71: 30:45:02:01:01:04:06:70:75:62:6c:69:63:a6:38:02:04:50:16:ab:c0:02:01:00:02:01:00:30:2a:30:0f:06:08:2b:06:01:02:01:01:03:00:43:03:00:9e:40:30:17:06:0a:2b:06:01:06:03:01:01:04:01:00:06:09:2b:06:01:06:03:01:01:05:05
java.net.BindException: Cannot assign requested address: Datagram send failed
VACM access requested for context=, securityName=public, securityModel=2, securityLevel=1, viewType=0, OID=1.3.6.1.6.3.1.1.5.5
Found group name ‘v1v2cgroup’ for secName ‘public’ and secModel 2
Got views [DefaultMOMutableRow2PC[index=10.118.49.118.50.99.103.114.111.117.112.0.1.1,values=[1, unrestrictedReadView, unrestrictedWriteView, unrestrictedNotifyView, 3, 1], DefaultMOMutableRow2PC[index=10.118.49.118.50.99.103.114.111.117.112.0.2.1,values=[1, unrestrictedReadView, unrestrictedWriteView, unrestrictedNotifyView, 3, 1]] for group name ‘v1v2cgroup’
Matching against access entry DefaultMOMutableRow2PC[index=10.118.49.118.50.99.103.114.111.117.112.0.1.1,values=[1, unrestrictedReadView, unrestrictedWriteView, unrestrictedNotifyView, 3, 1] with exactContextMatch=true, prefixMatch=false, matchSecModel=false and matchSecLevel=true
Matching against access entry DefaultMOMutableRow2PC[index=10.118.49.118.50.99.103.114.111.117.112.0.2.1,values=[1, unrestrictedReadView, unrestrictedWriteView, unrestrictedNotifyView, 3, 1] with exactContextMatch=true, prefixMatch=false, matchSecModel=true and matchSecLevel=true
Matching view found for group name ‘v1v2cgroup’ is ‘unrestrictedNotifyView’
Access allowed for view ‘unrestrictedNotifyView’ by subtree 1.3.6 for OID 1.3.6.1.6.3.1.1.5.5
Sending message to 127.0.0.1/162 with length 71: 30:45:02:01:01:04:06:70:75:62:6c:69:63:a7:38:02:04:50:16:ab:c1:02:01:00:02:01:00:30:2a:30:0f:06:08:2b:06:01:02:01:01:03:00:43:03:00:9e:41:30:17:06:0a:2b:06:01:06:03:01:01:04:01:00:06:09:2b:06:01:06:03:01:01:05:05
VACM access requested for context=, securityName=SHA256DES, securityModel=3, securityLevel=3, viewType=0, OID=1.3.6.1.6.3.1.1.5.5
Found group name ‘v3group’ for secName ‘SHA256DES’ and secModel 3
at java.net.DualStackPlainDatagramSocketImpl.socketSend(Native Method)
at java.net.DualStackPlainDatagramSocketImpl.send(Unknown Source)
at java.net.DatagramSocket.send(Unknown Source)
at org.snmp4j.transport.DefaultUdpTransportMapping.sendMessage(DefaultUdpTransportMapping.java:117)
at org.snmp4j.transport.UdpTransportMapping.sendMessage(UdpTransportMapping.java:1)
at org.snmp4j.MessageDispatcherImpl.sendMessage(MessageDispatcherImpl.java:203)
at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:522)
at org.snmp4j.Snmp.sendMessage(Snmp.java:1088)
at org.snmp4j.Snmp.send(Snmp.java:981)
at org.snmp4j.Snmp.send(Snmp.java:961)
at org.snmp4j.Snmp.send(Snmp.java:926)
at org.snmp4j.agent.mo.snmp.NotificationOriginatorImpl.sendNotification(NotificationOriginatorImpl.java:270)
at org.snmp4j.agent.mo.snmp.NotificationOriginatorImpl.notify(NotificationOriginatorImpl.java:376)
at org.snmp4j.agent.mo.snmp.NotificationOriginatorImpl.notify(NotificationOriginatorImpl.java:140)
at org.snmp4j.agent.NotificationTask.run(NotificationTask.java:68)
at org.snmp4j.util.ThreadPool$TaskManager.run(ThreadPool.java:312)
Failed to send notification: Cannot assign requested address: Datagram send failed

The exception is not caused by the target address. Instead it is the UDP port 8000 which is already used by another process on your system. With UDP a wrong/used target port will never return an error.

You can specify the target addresses in the SNMP-TARGET-MIB in conjunction with the SNMP-NOTIFICATION-MIB.

Hi,
" Instead it is the UDP port 8000 which is already used by another process on your system" - i am confused. 800 is the port where my snmp agent is listening for incoming requests. (i started my application with “-c udp:10.89.234.198/8000”)
when i debug the code i understand that it is trying to send a a packet to “127.0.0.1"162” (not sure from where did it get this target, i dont see any entry with that address in “SampleAgentConfig.properties” as well) using the 8000 port where my Agent is listening for incoming requests. now why it is again trying to bind to 8000 which already in use with itself?
code snippet:
DefaultUdpTransportMapping.sendMessage{
//
if (logger.isDebugEnabled()) {
logger.debug("Sending message to “+targetAddress+” with length “+
message.length+”: "+
new OctetString(message).toHexString());
}
DatagramSocket s = ensureSocket();
s.send(new DatagramPacket(message, message.length, targetSocketAddress));
}

The standard/sample agent will not bind the agent port twice.
Maybe you need to debug your setup?