confluentinc / schema-registry

Confluent Schema Registry for Kafka
https://docs.confluent.io/current/schema-registry/docs/index.html
Other
2.21k stars 1.12k forks source link

Can not use schema-registry:register goal of the maven plugin #751

Closed julienmmm closed 4 years ago

julienmmm commented 6 years ago

Hello,

When trying to register my avro schema to the schema registry with the maven plugin, as explained here: https://docs.confluent.io/current/schema-registry/docs/maven-plugin.html, I get the following error:

[ERROR] Failed to execute goal io.confluent:kafka-schema-registry-maven-plugin:4.0.0:register (default-cli) on project AvroTest: Execution default-cli of goal io.confluent:kafka-schema-registry-maven-plugin:4.0.0:register failed: A required class was missing while executing io.confluent:kafka-schema-registry-maven-plugin:4.0.0:register: com/fasterxml/jackson/core/type/TypeReference.

Here is the pom file I am using:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>be.belgianrail.kafka.avro</groupId>
<artifactId>AvroTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>AvroTest</name>
<description>AvroTest</description>

<repositories>
    <repository>
        <id>confluent</id>
        <url>http://packages.confluent.io/maven/</url>
    </repository>
</repositories>

<!-- Temporarily needed until Confluent 3.3.1 is released. -->
<pluginRepositories>
    <pluginRepository>
        <id>confluent</id>
        <url>http://packages.confluent.io/maven/</url>
    </pluginRepository>
</pluginRepositories>

<properties>
    <java.version>1.8</java.version>
    <avro.version>1.8.2</avro.version>
    <confluent.version>4.0.0</confluent.version>
    <slf4j.version>1.7.21</slf4j.version>
    <jackson.core.version>2.9.4</jackson.core.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.apache.avro</groupId>
        <artifactId>avro</artifactId>
        <version>${avro.version}</version>
    </dependency>
<dependency>
    <groupId>io.confluent</groupId>
    <artifactId>kafka-avro-serializer</artifactId>
    <version>${confluent.version}</version>
</dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>${slf4j.version}</version>
    </dependency>       
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <inherited>true</inherited>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro-maven-plugin</artifactId>
            <version>1.8.2</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>schema</goal>
                    </goals>
                    <configuration>
                        <sourceDirectory>${project.basedir}/src/main/avro/</sourceDirectory>
                        <outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>io.confluent</groupId>
            <artifactId>kafka-schema-registry-maven-plugin</artifactId>
            <version>${confluent.version}</version>
            <configuration>
                <schemaRegistryUrls>
                    <param>http://xxx:8081</param>
                </schemaRegistryUrls>
                <subjects>
                    <test_ri_tt-key>src/main/avro/trainkey.avsc</test_ri_tt-key>
                    <test_ri_rt-value>src/main/avro/timetable.avsc</test_ri_rt-value>
                </subjects>
            </configuration>
            <goals>
                <goal>register</goal>
            </goals>
        </plugin>
    </plugins>
</build>

julienmmm commented 6 years ago

I've found why it was not working. It seems that the plugin does not set the jackson dependcy.

If I modify the plugin definiytion of my pom file as shown bellow, it is working.

        <plugin>
            <groupId>io.confluent</groupId>
            <artifactId>kafka-schema-registry-maven-plugin</artifactId>
            <version>${confluent.version}</version>
            <configuration>
                <schemaRegistryUrls>
                    <param>http://desbv401.belgianrail.be:8081</param>
                </schemaRegistryUrls>
                <subjects>
                    <test_ri_tt-key>src/main/avro/trainkey.avsc</test_ri_tt-key>
                    <test_ri_rt-value>src/main/avro/timetable.avsc</test_ri_rt-value>
                </subjects>
            </configuration>
            <goals>
                <goal>register</goal>
            </goals>
            <dependencies>
                <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
                <dependency>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                    <version>2.9.4</version>
                </dependency>

            </dependencies>
        </plugin>

But is not preferable to modify the plugin to automatically manage this dependency?

rayokota commented 4 years ago

Closing this for now. Please reopen if it's still an issue.