Hi,

The error is not where you guessed it was.
Instead the error message gives the reason.
You have to use a ScopedPDU for SNMPv3.
So instead

PDU request=new PDU();

you have to use

ScopedPDU request=new ScopedPDU();

That is all.

Best regards,
Frank

Am 13.05.2016 um 12:10 schrieb atike.demir...@ogr.deu.edu.tr:
---------------------------- Original Message ----------------------------
Subject: java.lang.IllegalArgumentException error
From:    atike.demir...@ogr.deu.edu.tr
Date:    Wed, May 11, 2016 4:02 pm
To:      snmp4j@agentpp.org.
--------------------------------------------------------------------------

Hello,
I have developed an software for my school project. I have tried to
collect information on agent machines. When i do it for snmpv1, it is okay
but when i do it for snmpv3 i have an error. I have searched this problem
however i haven't found it. Please, help me.

There is my code;

Snmp client=null;
         try{
             client=new Snmp(new DefaultUdpTransportMapping());
             Address add=new UdpAddress("192.168.2.3/161");
             client.listen();

           //  USM usm=new USM(SecurityProtocols.getInstance(),new
//OctetString("MPv3.createLocalEngineID()"),0);
          //   SecurityModels.getInstance().addSecurityModel(usm);

              UsmUser user = new UsmUser(new OctetString("nagios"),
                                      AuthMD5.ID,
                                      new OctetString("User3Password"),
                                      PrivDES.ID,
                                      new OctetString("User3Encyrption"));
              client.getUSM().addUser(new OctetString("nagios"), user);

             UserTarget target=new UserTarget();
             target.setAddress(add);
             target.setRetries(2);
             target.setTimeout(1500);
             target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
             target.setSecurityModel(SecurityModel.SECURITY_MODEL_USM);
             target.setSecurityName(new OctetString("nagios"));

             PDU request=new PDU();
             request.setType(PDU.GET);
             OID oid=new OID(".1.3.6.1.2.1.1.5.0");
             request.add(new VariableBinding(oid));
             ResponseEvent event=client.send(request, target);
             System.out.println(event.getResponse());

         }

Error : java.lang.IllegalArgumentException: MPv3 only accepts ScopedPDU
instances as pdu parameter

This error point out "client.getUSM().addUser(new OctetString("nagios"),
user);"

Lots of example that i examined used "client.getUSM().addUser" but my code
is given me an error, i don't understand why it gave me.

Thanks for your help.


_______________________________________________
SNMP4J mailing list
SNMP4J@agentpp.org
https://oosnmp.net/mailman/listinfo/snmp4j

--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231

_______________________________________________
SNMP4J mailing list
SNMP4J@agentpp.org
https://oosnmp.net/mailman/listinfo/snmp4j

Reply via email to