[SNMP4J] Strange exception
Frank Fock
fock at agentpp.com
Wed Oct 13 20:39:22 CEST 2004
Hi Sasa,
I assume that you are using SNMP4J in a multi-threaded environment.
Then the following patch for org.snmp4j.smi.Variable could solve your
problem:
private synchronized static void registerSyntaxes() {
InputStream is =
Variable.class.getResourceAsStream(SMISYNTAXES_PROPERTIES);
if (is == null)
throw new InternalError("Could not read '"+SMISYNTAXES_PROPERTIES+
"' from classpath!");
Properties props = new Properties();
try {
props.load(is);
Hashtable regSyntaxes = new Hashtable(props.size());
for (Enumeration en = props.propertyNames(); en.hasMoreElements();) {
String id = (String)en.nextElement();
String className = props.getProperty(id);
try {
Class c = Class.forName(className);
regSyntaxes.put(new Integer(id), c);
}
catch (ClassNotFoundException cnfe) {
logger.fatal(cnfe);
}
}
// atomic syntax registration
registeredSyntaxes = regSyntaxes;
}
catch (IOException iox) {
String txt = "Could not read '"+SMISYNTAXES_PROPERTIES+"': "+
iox.getMessage();
logger.fatal(txt);
throw new InternalError(txt);
}
}
An updated SNMP4J release (v1.0.3a) will be available soon from
SNMP4J.org.
Best regards,
Frank
Sasa Markovic wrote:
> Hi,
>
> I have recently discovered SNMP4J and I want to say that this library
> is much better than any other free SNMP library. I have managed to
> port my existing java code to SNMP4J very quickly, but from time to
> time I get the following strange exception:
>
> ==========================================================
>
> java.io.IOException: Encountered unsupported variable syntax: 67
> at org.snmp4j.smi.Variable.createFromBER(Variable.java:120)
> at
> org.snmp4j.smi.VariableBinding.decodeBER(VariableBinding.java:143)
> at org.snmp4j.PDUv1.decodeBER(PDUv1.java:169)
> at org.snmp4j.mp.MPv1.prepareDataElements(MPv1.java:170)
> at
> org.snmp4j.MessageDispatcherImpl.dispatchMessage(MessageDispatcherImpl.java:204)
>
> at
> org.snmp4j.MessageDispatcherImpl.processMessage(MessageDispatcherImpl.java:263)
>
> at
> org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:172)
>
> java.io.IOException: Encountered unsupported variable syntax: 67
> at org.snmp4j.smi.Variable.createFromBER(Variable.java:120)
> at
> org.snmp4j.smi.VariableBinding.decodeBER(VariableBinding.java:143)
> at org.snmp4j.PDUv1.decodeBER(PDUv1.java:169)
> at org.snmp4j.mp.MPv1.prepareDataElements(MPv1.java:170)
> at
> org.snmp4j.MessageDispatcherImpl.dispatchMessage(MessageDispatcherImpl.java:204)
>
> at
> org.snmp4j.MessageDispatcherImpl.processMessage(MessageDispatcherImpl.java:263)
>
> at
> org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(DefaultUdpTransportMapping.java:172)
>
>
> ============================================
>
> I am using PDUv1 to sample some standard OIDs (ifInOctets, ifOutOctets
> and similar) - nothing more complicated than that. To make things more
> strange, this exception gets printed on the screen only from time to
> time - it does not appear on every SNMP request targeting the same OID
> on the same host. However, my application seems to be working properly
> but this exception is quite annoying.
>
> Thanx for the help.
>
> Best regards,
> Sasa Markovic
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://p15141779.pureserver.info/mailman/listinfo/snmp4j
>
More information about the SNMP4J
mailing list