Question

This is a really bizarre issue. I'm trying to upgrade snmp4j to the latest version (2.2.5) from 1.10.1 and now I'm getting a stackoverflowerror from within ActiveMQ (version 5.9.1). I have a bizarre work-around but it'd be interesting if anyone could shed more light on the issue.

The stackoverflow happens when snmp4j loads the SnmpRequest class and executes this static block:

static {
    LogFactory.setLogFactory(new Log4jLogFactory());
    org.apache.log4j.BasicConfigurator.configure();
    BER.setCheckSequenceLength(false);
  }

ActiveMQ blows up when the BasicConfigurator.configure() call is made. My work-around hack is to construct (load) an SnmpRequest object at startup (before ActiveMQ gets initialized). In snmp4j version 1.10.1 the SnmpRequest class has a different static block without the configure() call.

Below is the trace for the stackoverflowerror:

6688 [ActiveMQ VMTransport: vm://Server#1-1] SYSTM SystemError  -
4550 [ActiveMQ VMTransport: vm://Server#1-1] TRACE org
6689 [ActiveMQ VMTransport: vm://Server#1-1] SYSTM SystemError  - 
4550 [ActiveMQ VMTransport: vm://Server#1-1] TRACE org
6691 [ActiveMQ VMTransport: vm://Server#1-1] SYSTM SystemError  - 
4550 [ActiveMQ VMTransport: vm://JServer#1-1] TRACE org
6693 [ActiveMQ VMTransport: vm://Server#1-1] SYSTM SystemError  - 
4550 [ActiveMQ VMTransport: vm://Server#1-1]

This is going to stderr I believe, and it's all one big line.

Was it helpful?

Solution

There is probably a recursion from the Log4J initialization that calls your code with the use of the SnmpRequest class. The SnmpRequest class is an example only and should NOT be used in production code - one reason is the hard coded log initialization and its main method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top