[SNMP4J] Address type udp unknown

Frank Fock fock at agentpp.com
Wed Jul 21 00:06:32 CEST 2004


Hello Brian,

Until the next release is not out, you can use the following fix. Just
replace the method GenericAddress.registerAddressTypes by

  private static void registerAddressTypes() {
    InputStream is = 
Variable.class.getResourceAsStream(ADDRESS_TYPES_PROPERTIES);
    if (is == null)
      throw new InternalError("Could not read '"+ADDRESS_TYPES_PROPERTIES+
                              "' from classpath!");
    Properties props = new Properties();
    try {
      props.load(is);
      Hashtable h = new Hashtable(props.size()+1);
      for (Enumeration en = props.propertyNames(); en.hasMoreElements();) {
        String id = (String)en.nextElement();
        String className = props.getProperty(id);
        try {
          Class c = Class.forName(className);
          knownAddressTypes.put(id, c);
        }
        catch (ClassNotFoundException cnfe) {
          logger.fatal(cnfe);
        }
      }
      knownAddressTypes = h;
    }
    catch (IOException iox) {
      String txt = "Could not read '"+ADDRESS_TYPES_PROPERTIES+"': "+
                   iox.getMessage();
      logger.fatal(txt);
      throw new InternalError(txt);
    }
  }

Hope this helps.

Best regards,
Frank


Brian_Teravskis at cargill.com wrote:

>Hello,
>
>I'm using the SNMP4J library in a multithreaded program that polls
>various network devices for ARP cache information. Occasionally I get
>the following error on one or more of my threads:
>
>2004-07-20 11:32:48,784 ARPSlavePoller(42): Fatal error in polling,
>thread[1] terminating. 
>java.lang.IllegalArgumentException: Address type udp unknown
>      at org.snmp4j.smi.GenericAddress.parse(GenericAddress.java:157)
>      at com.cargill.rap.MySnmp.connect(MySnmp.java:66)
>      at com.cargill.rap.MACData.fetchMACsFromRouter(MACData.java:28)
>      at
>com.cargill.rap.ARPSlavePoller.startPolling(ARPSlavePoller.java:58)
>      at com.cargill.rap.ARPSlavePoller.run(ARPSlavePoller.java:40)
>      at java.lang.Thread.run(Unknown Source)
>
>I'm using version 1.0 of SNMP4J in a Windows base Java runtime
>enviroment running v 1.4.2_04. 
>
>Here is the connect code I am using:
>
>public void connect () {
>  String genericAddressString = PROTOCOL+":"+address+":"+PORT;
>  // System.out.println("SNMP Address String: "+genericAddressString);
>  if((targetAddress = GenericAddress.parse(genericAddressString)) ==
>null) {
>    System.out.println("Error in SNMP Address String:
>"+genericAddressString);
>  } else {
>    try {
>      transport = new DefaultUdpTransportMapping();
>      snmp = new Snmp(transport);
>
>      CommunityTarget cTarget = new CommunityTarget();
>      cTarget.setCommunity(new OctetString(community));
>      target = cTarget;
>
>      target.setVersion(version);
>      target.setRetries(retries);
>      target.setTimeout(socketTimeout);
>      target.setAddress(targetAddress);
>
>      transport.listen();
>      } catch (IOException ioe) {
>      System.err.println("Error while trying to 'connect': " +
>          targetAddress.toString() + "\n" +
>        ioe.getMessage());
>        ioe.printStackTrace();
>      }
>    }
>  }
>
>This does not bomb all of the time, but seems to be happening more and
>more. Is there something I should be doing special in a multi-threaded
>environment when I'm initializing the SNMP libraries?
>
>Thank you,
>
>Brian
>
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://p15141779.pureserver.info/mailman/listinfo/snmp4j
>
>  
>





More information about the SNMP4J mailing list