[SNMP4J] v3 NPE

Frank Fock fock at agentpp.com
Tue Jun 8 08:55:59 CEST 2004


Hi Zhan,

Caution! The SnmpRequest class is *not* designed to be used by
multiple threads concurrently! The SnmpRequest class is an example
implementation and must not be used to these kind of tests.

By using it in your way it will produce trash because the parameters
from the two threads will get mixed inside the SnmpRequest class!

Please use the Snmp class to implement your SNMP requests.

Best regards,
Frank

Zhan Yi wrote:

>Hi Frank,
>
>Below is the sample code that will reproduce the problem. 
>I have no way to solve this problem, can you give some advice.
>
>Best Regards
>Zhan Yi
>
>public class TestSnmp4J {
>    
>    public static void main(String [] args) throws Exception {
>        String [] params1={"-t", "5000", "-u","cisco","-a","MD5","-A","auth","-x","DES","-X","priv","-Ow","13.253.253.253/161", "1.3.6.1.2.1"};
>        walkThread(params1);
>        String [] params2={"-t", "5000", "-u","peter","-a","MD5","-A","12345678","-x","DES","-X","12345678", "-Ow", "13.100.200.39/161", "1.3.6.1.2.1"};
>        walkThread(params2);
>    }
>    
>    static void walkThread(final String [] params) {
>        new Thread(new Runnable() {
>            public void run() {
>                try {
>                    org.snmp4j.tools.console.SnmpRequest.main(params);
>                }catch(Exception ex) {
>                    ex.printStackTrace();
>                }
>            }
>        }).start();
>    }
>
>
>----- Original Message ----- 
>From: "Frank Fock" <fock at agentpp.com>
>To: "Zhan Yi" <zhanyi at vanlink.com.cn>
>Cc: <snmp4j at agentpp.org>
>Sent: Tuesday, June 08, 2004 3:02 AM
>Subject: Re: [SNMP4J] v3 NPE
>
>
>  
>
>>Hi Zhan,
>>
>>This error occurs when the USM returns an error while preparing
>>the outgoing message (most likely because the user is not known
>>to the USM which is referenced by the scoped PDU). That the NPE
>>is thrown is a bug, although it should not happen in a properly
>>setup application. The next SNMP4J version will throw a
>>MessageException here instead a NPE.
>>
>>Best regards,
>>Frank
>>
>>Zhan Yi wrote:
>>
>>    
>>
>>>Hi,
>>>
>>>I got NPE occasionally using snmp v3 and running multiple concurrent threads.
>>>Can you give some hint on how to understand and solve this problem? Using v1 there is no problem.
>>>
>>>java.lang.NullPointerException
>>>       at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:330)
>>>       at org.snmp4j.Snmp.send(Snmp.java:285)
>>>       at org.snmp4j.Snmp$PendingRequest.run(Snmp.java:661)
>>>       at java.util.TimerThread.mainLoop(Timer.java:432)
>>>       at java.util.TimerThread.run(Timer.java:382)
>>>
>>>Thank you!
>>>
>>>
>>>Best Regards
>>>Zhan Yi
>>> 
>>>
>>>------------------------------------------------------------------------
>>>
>>>_______________________________________________
>>>SNMP4J mailing list
>>>SNMP4J at agentpp.org
>>>http://p15141779.pureserver.info/mailman/listinfo/snmp4j
>>> 
>>>
>>>      
>>>
>>
>>    
>>





More information about the SNMP4J mailing list