Question

I'm writing a small Java application and having some trouble with log4j that appears to be caused by multiple, independent libraries trying to use it simultaneously:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.log4j.Logger.info(Ljava/lang/String;)V
    at twitter4j.internal.logging.Log4JLogger.info(Log4JLogger.java:85)
    at twitter4j.internal.logging.Logger.<clinit>(Logger.java:72)
    at twitter4j.http.BasicAuthorization.<clinit>(BasicAuthorization.java:43)
    at twitter4j.http.AuthorizationFactory.getBasicAuthorizationInstance(AuthorizationFactory.java:66)
    at twitter4j.TwitterStreamFactory.getInstance(TwitterStreamFactory.java:121)
    at org.voltdb.twitter.drivers.Collect.main(Collect.java:13)

The two libraries I'm using are Twitter4J and VoltDB. Both are in the form of JARs. If I use either in isolation, I don't run into this problem; both work fine on their own.

It would be acceptable to disable the log4j component of either library if this fixed the problem.

Was it helpful?

Solution 2

I came across a reply to a Twitter4J logging problem that shows how to disable logging:

-Dtwitter4j.loggerFactory=twitter4j.internal.logging.StdOutLoggerFactory

Adding this property made the exception disappear.

OTHER TIPS

Are you sure you're using the right version of log4j as required by both libraries? Your error message seems to indicate in incorrect log4j version IMO.

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