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
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
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
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