错误由于错误而停止(org.apache.kafka.connect.cli.ConnectStandalone)java.lang.NoClassDefFoundError:io / debezium / util / IoUtil

时间:2019-02-20 16:31:37

标签: windows apache-kafka apache-kafka-connect debezium

我正在尝试将SQL Server数据库连接到Windows上的kafka,我下载了Debezium jar文件,它们位于名为debezium-connector-sqlserver的文件夹中,如下所示:Kafka folder,{{ 3}}

我还在connect-standalone.properties中添加了这一行plugin.path=C:\\current_kafka_2.12-2.0.0\\debezium-connector-sqlserver,这是我从Debezium下载的所有jar文件的存放位置。

我还创建了一个名为connect-mssql.properties的文件,并将其放入其中。

name=inventory-connector
connector.class=io.debezium.connector.sqlserver.SqlServerConnector
tasks.max=2
database.hostname=DESKTOP-LMJGRO0
database.port=1433
database.user=sa
database.password=password
database.dbname=Source
database.history.kafka.bootstrap.servers=localhost:9092
database.history.kafka.topic=test
table.whitelist=dbo.guinea_pig_source

现在当我尝试运行此。\ bin \ windows \ connect-standalone。\ config \ connect-standalone.properties。\ config \ connect-mssql.properties

我收到以下错误:

[2019-02-20 17:18:39,794] ERROR Stopping due to error (org.apache.kafka.connect.cli.ConnectStandalone)
java.lang.NoClassDefFoundError: io/debezium/util/IoUtil
        at io.debezium.connector.sqlserver.Module.<clinit>(Module.java:19)
        at io.debezium.connector.sqlserver.SqlServerConnector.version(SqlServerConnector.java:29)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.versionFor(DelegatingClassLoader.java:346)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.versionFor(DelegatingClassLoader.java:351)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.getPluginDesc(DelegatingClassLoader.java:328)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scanPluginPath(DelegatingClassLoader.java:309)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scanUrlsAndAddPlugins(DelegatingClassLoader.java:240)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.registerPlugin(DelegatingClassLoader.java:232)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.initPluginLoader(DelegatingClassLoader.java:201)
        at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.initLoaders(DelegatingClassLoader.java:178)
        at org.apache.kafka.connect.runtime.isolation.Plugins.<init>(Plugins.java:61)
        at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:77)
Caused by: java.lang.ClassNotFoundException: io.debezium.util.IoUtil
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.apache.kafka.connect.runtime.isolation.PluginClassLoader.loadClass(PluginClassLoader.java:104)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 12 more

4 个答案:

答案 0 :(得分:0)

所有插件文件必须位于“ plugin.path =”的子目录中。例如,如果插件路径为:

// [...] Nothing to change in annotations
public class MyControllerTest {

    // [...] Nothing to change in the other fields

    @Value("${my.value}")
    private String myValue;

    @Before
    public void setup() throws NoSuchFieldException, IllegalAccessException {
        ReflectionTestUtils.setField(myServiceMock, "myValue", myValue); // thanks to @thomas-andolf's [answer](https://stackoverflow.com/a/55148170/535203)
        // // Equivalent with traditional reflection tools:
        // Field myValueField = MyService.class.getDeclaredField("myValue");
        // myValueField.setAccessible(true);
        // myValueField.set(myServiceMock, myValue);

        // [...] the rest of the original method
    }

    // [...] Nothing to change in the test methods
}

使用以下文件创建目录F:/ connect-plugins / mssql-debezium:

  • debezium-connector-sqlserver-0.9.2.Final.jar
  • debezium-core-0.9.2.Final.jar
  • mssql-jdbc-6.4.0.jre8.jar

答案 1 :(得分:0)

将连接器jar文件和kafka库文件添加到类路径:

在linux中: 导出CLASSPATH = $ CLASSPATH:/ debezium-connector-sqlserver / *

export CLASSPATH = $ CLASSPATH:// kafka / libs / *

答案 2 :(得分:0)

尝试将“ debezium-connector-sqlserver” 嵌套在另一个文件夹中,例如:“插件” 并将您的 connect-standalone.properties 更新为 plugin.path = C:\ current_kafka_2.12-2.0.0 \ plugins

因此您的目录结构将像 C:\ current_kafka_2.12-2.0.0 \ plugins \ debezium-connector-sqlserver 并且您的jar将位于“ debezium-connector-sqlserver”

答案 3 :(得分:0)

在插件路径变量的末尾添加斜杠解决了我的问题。

plugin.path=**C:/Application/kafka/plugins/**