NoSuchMethodError: org.apache.log4j.LogManager.getLoggerRepository()

4,121 views
Skip to first unread message

Thilo-Alexander Ginkel

unread,
Jan 7, 2011, 4:49:49 AM1/7/11
to hector...@googlegroups.com
Hi there,

I just switched from Hector 0.6.0-x to 0.7.0-22. Unfortunately, after
the migration my application is no longer starting up with the
following error:

java.lang.NoSuchMethodError:
org.apache.log4j.LogManager.getLoggerRepository()Lorg/apache/log4j/spi/LoggerRepository;
at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:901)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at me.prettyprint.cassandra.service.JmxMonitor.registerPerf4J(JmxMonitor.java:92)
at me.prettyprint.cassandra.service.JmxMonitor.registerMonitor(JmxMonitor.java:80)
at me.prettyprint.cassandra.service.JmxMonitor.<init>(JmxMonitor.java:39)
at me.prettyprint.cassandra.service.JmxMonitor.getInstance(JmxMonitor.java:54)
at me.prettyprint.cassandra.connection.HConnectionManager.<init>(HConnectionManager.java:75)
at me.prettyprint.cassandra.service.AbstractCluster.<init>(AbstractCluster.java:61)
at me.prettyprint.cassandra.service.AbstractCluster.<init>(AbstractCluster.java:57)
at me.prettyprint.cassandra.service.ThriftCluster.<init>(ThriftCluster.java:17)
at me.prettyprint.hector.api.factory.HFactory.createCluster(HFactory.java:112)
at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:104)
at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:96)
[...]

My project references log4j 1.2.16.

Has anyone seen this error before and could give me a hint which log4j
version is the right one to use?

Thanks,
Thilo

Ran Tavory

unread,
Jan 7, 2011, 5:05:51 AM1/7/11
to hector...@googlegroups.com
are you using maven to build? If so, then are you downloading the artifacts from mvn.riptano.com? They should have the correct dependencies. 
Anyways, you can look at the pom.xml files which list the correct versions. https://github.com/rantav/hector/blob/v0.7.0-21/core/pom.xml
If not then the zip files such as https://github.com/downloads/rantav/hector/hector-0.7.0-22.zip should have all the jars. 
--
/Ran

Thilo-Alexander Ginkel

unread,
Jan 7, 2011, 8:01:54 PM1/7/11
to hector...@googlegroups.com
On Jan 7, 2011 11:06 AM, "Ran Tavory" <ran...@gmail.com> wrote:
> are you using maven to build? If so, then are you downloading the artifacts
> from mvn.riptano.com? They should have the correct dependencies.
> Anyways, you can look at the pom.xml files which list the correct versions.
> https://github.com/rantav/hector/blob/v0.7.0-21/core/pom.xml

I am using sbt as build environment, which is using ivy2 / maven for
its dependency management, so I would have expected all dependencies
(even transitive ones) to be pulled in correctly.

Still, no luck. I'll do some further debugging tomorrow.

Regards,
Thilo

Thilo-Alexander Ginkel

unread,
Jan 9, 2011, 5:05:29 PM1/9/11
to hector...@googlegroups.com
On Sat, Jan 8, 2011 at 02:01, Thilo-Alexander Ginkel <th...@ginkel.com> wrote:
> On Jan 7, 2011 11:06 AM, "Ran Tavory" <ran...@gmail.com> wrote:
>> are you using maven to build? If so, then are you downloading the artifacts
>> from mvn.riptano.com? They should have the correct dependencies.
>> Anyways, you can look at the pom.xml files which list the correct versions.
>> https://github.com/rantav/hector/blob/v0.7.0-21/core/pom.xml
>
> I am using sbt as build environment, which is using ivy2 / maven for
> its dependency management, so I would have expected all dependencies
> (even transitive ones) to be pulled in correctly.

As it turned out, the cause for this NoSuchMethodError is an
incompatibility with SLF4J, which replaces log4j's LogManager class
(but does not provide a getLoggerRepository method).

I committed a kind of dirty workaround [1] to my fork. Not sure
whether this should make it into the main branch.

Regards,
Thilo

[1] https://github.com/ginkel/hector/commit/248a9f641f5df997d2b3f3610aa7ade1aab2feb1

Ran Tavory

unread,
Jan 10, 2011, 1:14:28 AM1/10/11
to hector...@googlegroups.com
SLF4J is actually used and defined in https://github.com/rantav/hector/blob/master/core/pom.xml.
So maybe the reason is version incompatibility or something. We use 1.6.1, see https://github.com/rantav/hector/blob/master/pom.xml#L267
--
/Ran

Thilo-Alexander Ginkel

unread,
Jan 10, 2011, 5:57:09 PM1/10/11
to hector...@googlegroups.com
On Mon, Jan 10, 2011 at 07:14, Ran Tavory <ran...@gmail.com> wrote:
> SLF4J is actually used and defined
> in https://github.com/rantav/hector/blob/master/core/pom.xml.
> So maybe the reason is version incompatibility or something. We use 1.6.1,
> see https://github.com/rantav/hector/blob/master/pom.xml#L267

You are right, SLF4J is not the root cause. log4j-over-slf4j is as it
is providing its own version of org.apache.log4j.LogManager, which
unfortunately does not provide a getLoggerRepository method.
log4j-over-slf4j is automatically pulled in by a dependency
(akka-persistence-voldemort), which I do not even use (so I may be
able to get rid of it), but the general problem remains.

Regards,
Thilo

B. Todd Burruss

unread,
Jan 10, 2011, 6:41:07 PM1/10/11
to hector...@googlegroups.com
i have run into the slf4j and slf4j-log4j12 incompatability problem a bunch.  1.5 and 1.6 are not compatible and will cause problems as u describe.  best if you can just be on the same version as what is in hector's pom.xml.  however, if you can't you can always do an exclusion like this in your pom.xml where you include hector

        <dependency>
            <groupId>me.prettyprint</groupId>
            <artifactId>hector-core</artifactId>
            <version>0.7.0-XX</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>jcl-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
Reply all
Reply to author
Forward
0 new messages