Search code examples
javamavenprotocol-buffersconfluent-schema-registry

Maven plugin with protobuf RestClientException: Unexpected character ('<' (code 60)):


i have a problem to get the maven plugin running in version 7.2.1. Versions of the server are also all 7.2.1. I have a simple development setup with kafka, zookeeper, schema registry and kqsldb. I configured the plugin according to the documentation and i always get the following error when I run the mojo register.

mvn -X -P Schema-registration kafka-schema-registry-maven-plugin:7.2.1:register

[DEBUG] Processing schema for subject(law-download-events-value).
[DEBUG] Calling register('law-download-events-value', 'syntax = "proto3";
package datamanager.entities;

option java_multiple_files = true;
option java_package = "org.mjm.DataManager.DMEntities.entities.protos";
option java_outer_classname = "LawDownloadEventProtos";
option optimize_for = SPEED;

message LawDownloadEvent {
  LawDownloadEventType type = 1;

  enum LawDownloadEventType {
    CHECK_DECISIONS = 0;
    CHECK_LAWS = 1;
  }
}
')
[DEBUG] Sending POST with input {"schemaType":"PROTOBUF","schema":"syntax = \"proto3\";\npackage datamanager.entities;\n\noption java_multiple_files = true;\noption java_package = \"org.mjm.DataManager.DMEntities.entities.protos\";\noption java_outer_classname = \"LawDownloadEventProtos\";\noption optimize_for = SPEED;\n\nmessage LawDownloadEvent {\n  LawDownloadEventType type = 1;\n\n  enum LawDownloadEventType {\n    CHECK_DECISIONS = 0;\n    CHECK_LAWS = 1;\n  }\n}\n"} to http://127.0.0.1:8098/subjects/law-download-events-value/versions?normalize=false
[ERROR] Exception thrown while processing law-download-events-value
io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number (or 'NaN'/'INF'/'+INF'), Array, Object or token 'null', 'true' or 'false')
 at [Source: (sun.net.www.protocol.http.HttpURLConnection$HttpInputStream); line: 1, column: 2]; error code: 50005
    at io.confluent.kafka.schemaregistry.client.rest.RestService.sendHttpRequest (RestService.java:301)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.httpRequest (RestService.java:371)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema (RestService.java:548)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema (RestService.java:536)
    at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema (RestService.java:494)
    at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.registerAndGetId (CachedSchemaRegistryClient.java:274)
    at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.register (CachedSchemaRegistryClient.java:381)
    at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.register (CachedSchemaRegistryClient.java:354)
    at io.confluent.kafka.schemaregistry.maven.RegisterSchemaRegistryMojo.processSchema (RegisterSchemaRegistryMojo.java:48)
    at io.confluent.kafka.schemaregistry.maven.UploadSchemaRegistryMojo.processSubject (UploadSchemaRegistryMojo.java:121)
    at io.confluent.kafka.schemaregistry.maven.UploadSchemaRegistryMojo.execute (UploadSchemaRegistryMojo.java:85)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
    at java.lang.reflect.Method.invoke (Method.java:577)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.474 s
[INFO] Finished at: 2022-08-28T12:15:08+02:00
[INFO] ------------------------------------------------------------------------

If I copy the schema from the post output and run it with curl (or Insomnia Rest Client) directly on the given url, it works normally. I can not find any solution to that problem. I checked all the files and the server logs and they are all fine (from my point of view).

Here is the config of the plugin:

<plugin>
                        <groupId>io.confluent</groupId>
                        <artifactId>kafka-schema-registry-maven-plugin</artifactId>
                        <version>7.2.1</version>
                        <configuration>
                            <schemaRegistryUrls>
                                <param>http://127.0.0.1:8098</param>
                            </schemaRegistryUrls>
                            <outputDirectory>src/main/proto/downloaded</outputDirectory>
                            <subjects>
                                <law-download-events-value>src/main/proto/law_download_event_proto.proto</law-download-events-value>
                            </subjects>
                            <schemaTypes>
                                <law-download-events-value>PROTOBUF</law-download-events-value>
                            </schemaTypes>
                            <compatibilityLevels/>
                            <previousSchemaPaths/>
                            <schemas/>
                        </configuration>
                    </plugin>

Here is the example protobuf file:

syntax = "proto3";

package datamanager.entities;

option java_multiple_files = true;
option java_package = "org.mjm.DataManager.DMEntities.entities.protos";
option java_outer_classname = "LawDownloadEventProtos";
option optimize_for = SPEED;

message LawDownloadEvent {
  LawDownloadEventType type = 1;

  enum LawDownloadEventType {
    CHECK_DECISIONS = 0;
    CHECK_LAWS = 1;
  }
}

I don't know where to look anymore. Any help is more than welcome. Thanks in advance ...

Best Martin


Solution

  • I answer my own question and hope it helps someone. If you have this error, check the connection to the schema server. A bit embarrassing that I totally oversaw the typo in the port, but sometimes it happens that you do not see your obvious mistakes. Thanks to @OneCricketeer pointed me in that direction, so that i checked this setting again.