scylladb / scylla-cdc-source-connector

A Kafka source connector capturing Scylla CDC changes
Apache License 2.0
46 stars 18 forks source link

NoSuchMethodException #29

Closed wyfo closed 3 months ago

wyfo commented 1 year ago

Commit https://github.com/scylladb/scylla-cdc-source-connector/commit/80b7117af97ce6bda360319d70968a97252d826d introduced a bug by updating flogger dependency version from 0.5.1 to 0.7.4.

Indeed, these lines of code https://github.com/scylladb/scylla-cdc-source-connector/blob/master/src/main/java/com/scylladb/cdc/debezium/connector/ScyllaConnector.java#L36-L38 trigger

java.lang.NoSuchMethodException: com.google.common.flogger.backend.log4j.Log4jBackendFactory.getInstance()
avelanarius commented 1 year ago

@wyfo For us to quicker solve the problem, could you specify the environment you launch the connector in? (whether using the "fat jar" (jar-with-dependencies) or "Confluent Hub ZIP package", version of Kafka (Confluent/open-source), maybe some non-standard logging configuration)

wyfo commented 1 year ago

I hit the issue while writing #28, in a basic test I had written for the occasion to test the SSL connection, so JUnit, with maven install plugin to install locally the modified https://github.com/scylladb/scylla-cdc-java dependency.

Anyway, com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance doesn't exists in flogger 0.7.4 https://javadoc.io/doc/com.google.flogger/flogger-log4j-backend/0.7.4/com/google/common/flogger/backend/log4j/Log4jBackendFactory.html (vs https://javadoc.io/doc/com.google.flogger/flogger-log4j-backend/0.5.1/index.html where it exists).

I know that https://github.com/scylladb/scylla-cdc-java/blob/master/pom.xml#L23 dependency still uses version 0.5.1, so maybe some maven black magic should normally happen (I'm quite a noob concerning maven), but it did not in my test and I had this error.

Bouncheck commented 1 year ago

Thanks for raising this issue. I must have not noticed it when running the connector. I have been playing around with this recently and here's what I have found so far:

Silver lining is that somehow most of the logging still works. I still can see flogger logs originating from scylla-cdc-base, although in a different format from other logs. Possibly because it goes through different logging backend since I messed up setting the property.

I tried both fixing the property and reverting to state before faulty commit, but it turns out there's a little larger issue with that. Right now it results in swapping NoSuchMethodException with ClassCastException (this is Flogger 0.5.1 with fixed property):

class shaded.com.scylladb.cdc.driver3.common.flogger.util.StaticMethodCaller: 
  cannot cast result of calling 'com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance' to
  'shaded.com.scylladb.cdc.driver3.common.flogger.backend.system.BackendFactory': 
    java.lang.ClassCastException: Cannot cast com.google.common.flogger.backend.log4j.Log4jBackendFactory to 
    shaded.com.scylladb.cdc.driver3.common.flogger.backend.system.BackendFactory

It seems that because scylla-cdc-driver3 shades and relocates its flogger dependencies it (correctly) does not recognize that backend provided with cdc connector dependencies could be cast to BackendFactory in different circumstances. I'll see what happens locally when I unshade this dependency and I'll try to use this opportunity to switch to flogger-log4j2-backend version 0.5.1 at the same time.

roydahan commented 3 months ago

Fixed as part of https://github.com/scylladb/scylla-cdc-java/pull/73.