oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.33k stars 1.63k forks source link

Kafka sasl authentication failure with NullPointerException #4089

Open han1448 opened 2 years ago

han1448 commented 2 years ago

Describe the issue I got NullPointerException error when trying to authenticate with kafka sasl. I already reported an issue to spring native a few months ago, but I'm curious about the current situation. I tried again with the latest version but got the same error. This app works fine without native image.

Steps to reproduce the issue

git clone https://github.com/han1448/kafka-sasl-native
./mvnw -Pnative -DskipTests clean package

Note: Need to change topic, kafka broker, sasl information.

Describe GraalVM and your environment:

More details build logs

./mvnw -Pnative -DskipTests clean package
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< com.example:kafka-sasl >-----------------------
[INFO] Building kafka-sasl 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ kafka-sasl ---
[INFO] Deleting /Users/user/IdeaProjectsHans/kafka-sasl/target
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ kafka-sasl ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ kafka-sasl ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- kotlin-maven-plugin:1.5.31:compile (compile) @ kafka-sasl ---
[INFO] Applied plugin: 'spring'
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ kafka-sasl ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /Users/user/IdeaProjectsHans/kafka-sasl/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ kafka-sasl ---
[INFO] Changes detected - recompiling the module!
[INFO] 
[INFO] --- kotlin-maven-plugin:1.5.31:test-compile (test-compile) @ kafka-sasl ---
[WARNING] No sources found skipping Kotlin compile
[INFO] 
[INFO] --- spring-aot-maven-plugin:0.10.5:test-generate (test-generate) @ kafka-sasl ---
[INFO] Spring Native operating mode: native
[WARNING] Failed verification check: Invalid attempt to add bundle to configuration, no bundles found for this pattern: org.aspectj.weaver.weaver-messages
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.data.jpa.repository.support.EntityManagerBeanDefinitionRegistrarPostProcessor it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: javax.transaction.Transactional it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.ExceptionHandler it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestMethod[] it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.ModelAttribute it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.InitBinder it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestMethod it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.ResponseBody it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestBody it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestHeader it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RestController it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestParam it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestPart it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.PathVariable it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.Mapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.GetMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.PostMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.PutMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.DeleteMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.PatchMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.ResponseStatus it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.http.HttpStatus it will be skipped
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 26 source files to /Users/user/IdeaProjectsHans/kafka-sasl/target/test-classes
[INFO] /Users/user/IdeaProjectsHans/kafka-sasl/target/generated-test-sources/spring-aot/src/test/java/org/springframework/aot/StaticSpringFactories.java: Some input files use or override a deprecated API.
[INFO] /Users/user/IdeaProjectsHans/kafka-sasl/target/generated-test-sources/spring-aot/src/test/java/org/springframework/aot/StaticSpringFactories.java: Recompile with -Xlint:deprecation for details.
[INFO] /Users/user/IdeaProjectsHans/kafka-sasl/target/generated-test-sources/spring-aot/src/test/java/org/springframework/aot/StaticSpringFactories.java: /Users/user/IdeaProjectsHans/kafka-sasl/target/generated-test-sources/spring-aot/src/test/java/org/springframework/aot/StaticSpringFactories.java uses unchecked or unsafe operations.
[INFO] /Users/user/IdeaProjectsHans/kafka-sasl/target/generated-test-sources/spring-aot/src/test/java/org/springframework/aot/StaticSpringFactories.java: Recompile with -Xlint:unchecked for details.
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 6 resources
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ kafka-sasl ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- native-maven-plugin:0.9.4:test (test-native) @ kafka-sasl ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- spring-aot-maven-plugin:0.10.5:generate (generate) @ kafka-sasl ---
[INFO] Spring Native operating mode: native
[WARNING] Failed verification check: Invalid attempt to add bundle to configuration, no bundles found for this pattern: org.aspectj.weaver.weaver-messages
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.data.jpa.repository.support.EntityManagerBeanDefinitionRegistrarPostProcessor it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: javax.transaction.Transactional it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.ExceptionHandler it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestMethod[] it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.ModelAttribute it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.InitBinder it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestMethod it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.ResponseBody it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestBody it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestHeader it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RestController it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestParam it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestPart it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.PathVariable it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.Mapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.RequestMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.GetMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.PostMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.PutMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.DeleteMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.PatchMapping it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.web.bind.annotation.ResponseStatus it will be skipped
[WARNING] Failed verification check: this type was requested to be added to configuration but is not resolvable: org.springframework.http.HttpStatus it will be skipped
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 26 source files to /Users/user/IdeaProjectsHans/kafka-sasl/target/classes
[INFO] /Users/user/IdeaProjectsHans/kafka-sasl/target/generated-sources/spring-aot/src/main/java/org/springframework/boot/autoconfigure/flyway/_FactoryProvider.java: Some input files use or override a deprecated API.
[INFO] /Users/user/IdeaProjectsHans/kafka-sasl/target/generated-sources/spring-aot/src/main/java/org/springframework/boot/autoconfigure/flyway/_FactoryProvider.java: Recompile with -Xlint:deprecation for details.
[INFO] /Users/user/IdeaProjectsHans/kafka-sasl/target/generated-sources/spring-aot/src/main/java/org/springframework/aot/StaticSpringFactories.java: /Users/user/IdeaProjectsHans/kafka-sasl/target/generated-sources/spring-aot/src/main/java/org/springframework/aot/StaticSpringFactories.java uses unchecked or unsafe operations.
[INFO] /Users/user/IdeaProjectsHans/kafka-sasl/target/generated-sources/spring-aot/src/main/java/org/springframework/aot/StaticSpringFactories.java: Recompile with -Xlint:unchecked for details.
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 6 resources
[INFO] 
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ kafka-sasl ---
[INFO] Building jar: /Users/user/IdeaProjectsHans/kafka-sasl/target/kafka-sasl-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.5.6:repackage (repackage) @ kafka-sasl ---
[INFO] Attaching repackaged archive /Users/user/IdeaProjectsHans/kafka-sasl/target/kafka-sasl-0.0.1-SNAPSHOT-exec.jar with classifier exec
[INFO] 
[INFO] --- native-maven-plugin:0.9.4:build (build-native) @ kafka-sasl ---
[INFO] ImageClasspath Entry: org.jetbrains.kotlin:kotlin-reflect:jar:1.5.31:compile (file:///Users/user/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.5.31/kotlin-reflect-1.5.31.jar)
[INFO] ImageClasspath Entry: org.jetbrains.kotlin:kotlin-stdlib:jar:1.5.31:compile (file:///Users/user/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.5.31/kotlin-stdlib-1.5.31.jar)
[INFO] ImageClasspath Entry: org.jetbrains:annotations:jar:13.0:compile (file:///Users/user/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar)
[INFO] ImageClasspath Entry: org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.5.31:compile (file:///Users/user/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.31/kotlin-stdlib-common-1.5.31.jar)
[INFO] ImageClasspath Entry: org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.5.31:compile (file:///Users/user/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.5.31/kotlin-stdlib-jdk8-1.5.31.jar)
[INFO] ImageClasspath Entry: org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.5.31:compile (file:///Users/user/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.5.31/kotlin-stdlib-jdk7-1.5.31.jar)
[INFO] ImageClasspath Entry: org.springframework.cloud:spring-cloud-stream:jar:3.1.4:compile (file:///Users/user/.m2/repository/org/springframework/cloud/spring-cloud-stream/3.1.4/spring-cloud-stream-3.1.4.jar)
[INFO] ImageClasspath Entry: org.springframework.boot:spring-boot-starter-validation:jar:2.5.6:compile (file:///Users/user/.m2/repository/org/springframework/boot/spring-boot-starter-validation/2.5.6/spring-boot-starter-validation-2.5.6.jar)
[INFO] ImageClasspath Entry: org.springframework.boot:spring-boot-starter:jar:2.5.6:compile (file:///Users/user/.m2/repository/org/springframework/boot/spring-boot-starter/2.5.6/spring-boot-starter-2.5.6.jar)
[INFO] ImageClasspath Entry: org.springframework.boot:spring-boot:jar:2.5.6:compile (file:///Users/user/.m2/repository/org/springframework/boot/spring-boot/2.5.6/spring-boot-2.5.6.jar)
[INFO] ImageClasspath Entry: org.springframework.boot:spring-boot-starter-logging:jar:2.5.6:compile (file:///Users/user/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.5.6/spring-boot-starter-logging-2.5.6.jar)
[INFO] ImageClasspath Entry: ch.qos.logback:logback-classic:jar:1.2.6:compile (file:///Users/user/.m2/repository/ch/qos/logback/logback-classic/1.2.6/logback-classic-1.2.6.jar)
[INFO] ImageClasspath Entry: ch.qos.logback:logback-core:jar:1.2.6:compile (file:///Users/user/.m2/repository/ch/qos/logback/logback-core/1.2.6/logback-core-1.2.6.jar)
[INFO] ImageClasspath Entry: org.apache.logging.log4j:log4j-to-slf4j:jar:2.14.1:compile (file:///Users/user/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.14.1/log4j-to-slf4j-2.14.1.jar)
[INFO] ImageClasspath Entry: org.apache.logging.log4j:log4j-api:jar:2.14.1:compile (file:///Users/user/.m2/repository/org/apache/logging/log4j/log4j-api/2.14.1/log4j-api-2.14.1.jar)
[INFO] ImageClasspath Entry: org.slf4j:jul-to-slf4j:jar:1.7.32:compile (file:///Users/user/.m2/repository/org/slf4j/jul-to-slf4j/1.7.32/jul-to-slf4j-1.7.32.jar)
[INFO] ImageClasspath Entry: jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile (file:///Users/user/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar)
[INFO] ImageClasspath Entry: org.yaml:snakeyaml:jar:1.28:compile (file:///Users/user/.m2/repository/org/yaml/snakeyaml/1.28/snakeyaml-1.28.jar)
[INFO] ImageClasspath Entry: org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.54:compile (file:///Users/user/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.54/tomcat-embed-el-9.0.54.jar)
[INFO] ImageClasspath Entry: org.hibernate.validator:hibernate-validator:jar:6.2.0.Final:compile (file:///Users/user/.m2/repository/org/hibernate/validator/hibernate-validator/6.2.0.Final/hibernate-validator-6.2.0.Final.jar)
[INFO] ImageClasspath Entry: jakarta.validation:jakarta.validation-api:jar:2.0.2:compile (file:///Users/user/.m2/repository/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.jar)
[INFO] ImageClasspath Entry: org.jboss.logging:jboss-logging:jar:3.4.2.Final:compile (file:///Users/user/.m2/repository/org/jboss/logging/jboss-logging/3.4.2.Final/jboss-logging-3.4.2.Final.jar)
[INFO] ImageClasspath Entry: com.fasterxml:classmate:jar:1.5.1:compile (file:///Users/user/.m2/repository/com/fasterxml/classmate/1.5.1/classmate-1.5.1.jar)
[INFO] ImageClasspath Entry: org.springframework:spring-messaging:jar:5.3.12:compile (file:///Users/user/.m2/repository/org/springframework/spring-messaging/5.3.12/spring-messaging-5.3.12.jar)
[INFO] ImageClasspath Entry: org.springframework:spring-beans:jar:5.3.12:compile (file:///Users/user/.m2/repository/org/springframework/spring-beans/5.3.12/spring-beans-5.3.12.jar)
[INFO] ImageClasspath Entry: org.springframework:spring-core:jar:5.3.12:compile (file:///Users/user/.m2/repository/org/springframework/spring-core/5.3.12/spring-core-5.3.12.jar)
[INFO] ImageClasspath Entry: org.springframework:spring-jcl:jar:5.3.12:compile (file:///Users/user/.m2/repository/org/springframework/spring-jcl/5.3.12/spring-jcl-5.3.12.jar)
[INFO] ImageClasspath Entry: org.springframework.integration:spring-integration-core:jar:5.5.5:compile (file:///Users/user/.m2/repository/org/springframework/integration/spring-integration-core/5.5.5/spring-integration-core-5.5.5.jar)
[INFO] ImageClasspath Entry: org.springframework:spring-aop:jar:5.3.12:compile (file:///Users/user/.m2/repository/org/springframework/spring-aop/5.3.12/spring-aop-5.3.12.jar)
[INFO] ImageClasspath Entry: org.springframework:spring-context:jar:5.3.12:compile (file:///Users/user/.m2/repository/org/springframework/spring-context/5.3.12/spring-context-5.3.12.jar)
[INFO] ImageClasspath Entry: org.springframework:spring-expression:jar:5.3.12:compile (file:///Users/user/.m2/repository/org/springframework/spring-expression/5.3.12/spring-expression-5.3.12.jar)
[INFO] ImageClasspath Entry: org.springframework:spring-tx:jar:5.3.12:compile (file:///Users/user/.m2/repository/org/springframework/spring-tx/5.3.12/spring-tx-5.3.12.jar)
[INFO] ImageClasspath Entry: io.projectreactor:reactor-core:jar:3.4.11:compile (file:///Users/user/.m2/repository/io/projectreactor/reactor-core/3.4.11/reactor-core-3.4.11.jar)
[INFO] ImageClasspath Entry: org.reactivestreams:reactive-streams:jar:1.0.3:compile (file:///Users/user/.m2/repository/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar)
[INFO] ImageClasspath Entry: org.springframework.integration:spring-integration-jmx:jar:5.5.5:compile (file:///Users/user/.m2/repository/org/springframework/integration/spring-integration-jmx/5.5.5/spring-integration-jmx-5.5.5.jar)
[INFO] ImageClasspath Entry: org.springframework.retry:spring-retry:jar:1.3.1:compile (file:///Users/user/.m2/repository/org/springframework/retry/spring-retry/1.3.1/spring-retry-1.3.1.jar)
[INFO] ImageClasspath Entry: javax.annotation:javax.annotation-api:jar:1.3.2:compile (file:///Users/user/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar)
[INFO] ImageClasspath Entry: org.springframework.cloud:spring-cloud-function-context:jar:3.1.4:compile (file:///Users/user/.m2/repository/org/springframework/cloud/spring-cloud-function-context/3.1.4/spring-cloud-function-context-3.1.4.jar)
[INFO] ImageClasspath Entry: net.jodah:typetools:jar:0.6.2:compile (file:///Users/user/.m2/repository/net/jodah/typetools/0.6.2/typetools-0.6.2.jar)
[INFO] ImageClasspath Entry: org.springframework.boot:spring-boot-autoconfigure:jar:2.5.6:compile (file:///Users/user/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.5.6/spring-boot-autoconfigure-2.5.6.jar)
[INFO] ImageClasspath Entry: org.springframework.cloud:spring-cloud-function-core:jar:3.1.4:compile (file:///Users/user/.m2/repository/org/springframework/cloud/spring-cloud-function-core/3.1.4/spring-cloud-function-core-3.1.4.jar)
[INFO] ImageClasspath Entry: com.fasterxml.jackson.core:jackson-databind:jar:2.12.5:compile (file:///Users/user/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.12.5/jackson-databind-2.12.5.jar)
[INFO] ImageClasspath Entry: com.fasterxml.jackson.core:jackson-annotations:jar:2.12.5:compile (file:///Users/user/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.12.5/jackson-annotations-2.12.5.jar)
[INFO] ImageClasspath Entry: com.fasterxml.jackson.core:jackson-core:jar:2.12.5:compile (file:///Users/user/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.12.5/jackson-core-2.12.5.jar)
[INFO] ImageClasspath Entry: org.springframework.cloud:spring-cloud-stream-binder-kafka:jar:3.1.4:compile (file:///Users/user/.m2/repository/org/springframework/cloud/spring-cloud-stream-binder-kafka/3.1.4/spring-cloud-stream-binder-kafka-3.1.4.jar)
[INFO] ImageClasspath Entry: org.springframework.cloud:spring-cloud-stream-binder-kafka-core:jar:3.1.4:compile (file:///Users/user/.m2/repository/org/springframework/cloud/spring-cloud-stream-binder-kafka-core/3.1.4/spring-cloud-stream-binder-kafka-core-3.1.4.jar)
[INFO] ImageClasspath Entry: org.springframework.integration:spring-integration-kafka:jar:5.5.5:compile (file:///Users/user/.m2/repository/org/springframework/integration/spring-integration-kafka/5.5.5/spring-integration-kafka-5.5.5.jar)
[INFO] ImageClasspath Entry: org.apache.kafka:kafka-clients:jar:2.7.1:compile (file:///Users/user/.m2/repository/org/apache/kafka/kafka-clients/2.7.1/kafka-clients-2.7.1.jar)
[INFO] ImageClasspath Entry: com.github.luben:zstd-jni:jar:1.4.5-6:compile (file:///Users/user/.m2/repository/com/github/luben/zstd-jni/1.4.5-6/zstd-jni-1.4.5-6.jar)
[INFO] ImageClasspath Entry: org.lz4:lz4-java:jar:1.7.1:compile (file:///Users/user/.m2/repository/org/lz4/lz4-java/1.7.1/lz4-java-1.7.1.jar)
[INFO] ImageClasspath Entry: org.xerial.snappy:snappy-java:jar:1.1.7.7:compile (file:///Users/user/.m2/repository/org/xerial/snappy/snappy-java/1.1.7.7/snappy-java-1.1.7.7.jar)
[INFO] ImageClasspath Entry: org.slf4j:slf4j-api:jar:1.7.32:compile (file:///Users/user/.m2/repository/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar)
[INFO] ImageClasspath Entry: org.springframework.kafka:spring-kafka:jar:2.7.8:compile (file:///Users/user/.m2/repository/org/springframework/kafka/spring-kafka/2.7.8/spring-kafka-2.7.8.jar)
[INFO] ImageClasspath Entry: com.google.code.findbugs:jsr305:jar:3.0.2:runtime (file:///Users/user/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar)
[INFO] ImageClasspath Entry: org.springframework.experimental:spring-native:jar:0.10.5:compile (file:///Users/user/.m2/repository/org/springframework/experimental/spring-native/0.10.5/spring-native-0.10.5.jar)
[INFO] ImageClasspath Entry: com.example:kafka-sasl:jar:0.0.1-SNAPSHOT (file:///Users/user/IdeaProjectsHans/kafka-sasl/target/kafka-sasl-0.0.1-SNAPSHOT.jar)
[WARNING] jar:file:///Users/user/IdeaProjectsHans/kafka-sasl/target/kafka-sasl-0.0.1-SNAPSHOT.jar!/META-INF/native-image/org.springframework.aot/spring-aot/native-image.properties does not match recommended META-INF/native-image/${groupId}/${artifactId}/native-image.properties layout.
[INFO] Executing: /Users/user/.sdkman/candidates/java/current/bin/native-image -cp /Users/user/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.5.31/kotlin-reflect-1.5.31.jar:/Users/user/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.5.31/kotlin-stdlib-1.5.31.jar:/Users/user/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar:/Users/user/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.31/kotlin-stdlib-common-1.5.31.jar:/Users/user/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.5.31/kotlin-stdlib-jdk8-1.5.31.jar:/Users/user/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.5.31/kotlin-stdlib-jdk7-1.5.31.jar:/Users/user/.m2/repository/org/springframework/cloud/spring-cloud-stream/3.1.4/spring-cloud-stream-3.1.4.jar:/Users/user/.m2/repository/org/springframework/boot/spring-boot-starter-validation/2.5.6/spring-boot-starter-validation-2.5.6.jar:/Users/user/.m2/repository/org/springframework/boot/spring-boot-starter/2.5.6/spring-boot-starter-2.5.6.jar:/Users/user/.m2/repository/org/springframework/boot/spring-boot/2.5.6/spring-boot-2.5.6.jar:/Users/user/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.5.6/spring-boot-starter-logging-2.5.6.jar:/Users/user/.m2/repository/ch/qos/logback/logback-classic/1.2.6/logback-classic-1.2.6.jar:/Users/user/.m2/repository/ch/qos/logback/logback-core/1.2.6/logback-core-1.2.6.jar:/Users/user/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.14.1/log4j-to-slf4j-2.14.1.jar:/Users/user/.m2/repository/org/apache/logging/log4j/log4j-api/2.14.1/log4j-api-2.14.1.jar:/Users/user/.m2/repository/org/slf4j/jul-to-slf4j/1.7.32/jul-to-slf4j-1.7.32.jar:/Users/user/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/user/.m2/repository/org/yaml/snakeyaml/1.28/snakeyaml-1.28.jar:/Users/user/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.54/tomcat-embed-el-9.0.54.jar:/Users/user/.m2/repository/org/hibernate/validator/hibernate-validator/6.2.0.Final/hibernate-validator-6.2.0.Final.jar:/Users/user/.m2/repository/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.jar:/Users/user/.m2/repository/org/jboss/logging/jboss-logging/3.4.2.Final/jboss-logging-3.4.2.Final.jar:/Users/user/.m2/repository/com/fasterxml/classmate/1.5.1/classmate-1.5.1.jar:/Users/user/.m2/repository/org/springframework/spring-messaging/5.3.12/spring-messaging-5.3.12.jar:/Users/user/.m2/repository/org/springframework/spring-beans/5.3.12/spring-beans-5.3.12.jar:/Users/user/.m2/repository/org/springframework/spring-core/5.3.12/spring-core-5.3.12.jar:/Users/user/.m2/repository/org/springframework/spring-jcl/5.3.12/spring-jcl-5.3.12.jar:/Users/user/.m2/repository/org/springframework/integration/spring-integration-core/5.5.5/spring-integration-core-5.5.5.jar:/Users/user/.m2/repository/org/springframework/spring-aop/5.3.12/spring-aop-5.3.12.jar:/Users/user/.m2/repository/org/springframework/spring-context/5.3.12/spring-context-5.3.12.jar:/Users/user/.m2/repository/org/springframework/spring-expression/5.3.12/spring-expression-5.3.12.jar:/Users/user/.m2/repository/org/springframework/spring-tx/5.3.12/spring-tx-5.3.12.jar:/Users/user/.m2/repository/io/projectreactor/reactor-core/3.4.11/reactor-core-3.4.11.jar:/Users/user/.m2/repository/org/reactivestreams/reactive-streams/1.0.3/reactive-streams-1.0.3.jar:/Users/user/.m2/repository/org/springframework/integration/spring-integration-jmx/5.5.5/spring-integration-jmx-5.5.5.jar:/Users/user/.m2/repository/org/springframework/retry/spring-retry/1.3.1/spring-retry-1.3.1.jar:/Users/user/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/Users/user/.m2/repository/org/springframework/cloud/spring-cloud-function-context/3.1.4/spring-cloud-function-context-3.1.4.jar:/Users/user/.m2/repository/net/jodah/typetools/0.6.2/typetools-0.6.2.jar:/Users/user/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.5.6/spring-boot-autoconfigure-2.5.6.jar:/Users/user/.m2/repository/org/springframework/cloud/spring-cloud-function-core/3.1.4/spring-cloud-function-core-3.1.4.jar:/Users/user/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.12.5/jackson-databind-2.12.5.jar:/Users/user/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.12.5/jackson-annotations-2.12.5.jar:/Users/user/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.12.5/jackson-core-2.12.5.jar:/Users/user/.m2/repository/org/springframework/cloud/spring-cloud-stream-binder-kafka/3.1.4/spring-cloud-stream-binder-kafka-3.1.4.jar:/Users/user/.m2/repository/org/springframework/cloud/spring-cloud-stream-binder-kafka-core/3.1.4/spring-cloud-stream-binder-kafka-core-3.1.4.jar:/Users/user/.m2/repository/org/springframework/integration/spring-integration-kafka/5.5.5/spring-integration-kafka-5.5.5.jar:/Users/user/.m2/repository/org/apache/kafka/kafka-clients/2.7.1/kafka-clients-2.7.1.jar:/Users/user/.m2/repository/com/github/luben/zstd-jni/1.4.5-6/zstd-jni-1.4.5-6.jar:/Users/user/.m2/repository/org/lz4/lz4-java/1.7.1/lz4-java-1.7.1.jar:/Users/user/.m2/repository/org/xerial/snappy/snappy-java/1.1.7.7/snappy-java-1.1.7.7.jar:/Users/user/.m2/repository/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar:/Users/user/.m2/repository/org/springframework/kafka/spring-kafka/2.7.8/spring-kafka-2.7.8.jar:/Users/user/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/Users/user/.m2/repository/org/springframework/experimental/spring-native/0.10.5/spring-native-0.10.5.jar:/Users/user/IdeaProjectsHans/kafka-sasl/target/kafka-sasl-0.0.1-SNAPSHOT.jar --enable-https -H:IncludeResourceBundles=sun.security.util.Resources -H:Name=kafka-sasl
[kafka-sasl:6976]    classlist:   5,048.07 ms,  1.19 GB
16:28:56.743 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Log4j2LoggerProvider
[kafka-sasl:6976]        (cap):   4,083.41 ms,  1.19 GB
Warning: Could not register org.springframework.cloud.stream.binder.kafka.config.KafkaBinderHealthIndicatorConfiguration: allDeclaredMethods for reflection. Reason: java.lang.NoClassDefFoundError: org/springframework/boot/actuate/health/HealthIndicator.
Warning: Could not register org.springframework.integration.json.JsonPathUtils: allPublicMethods for reflection. Reason: java.lang.NoClassDefFoundError: [Lcom/jayway/jsonpath/Predicate;.
[kafka-sasl:6976]        setup:   6,760.99 ms,  1.19 GB
Warning: Could not register complete reflection metadata for org.springframework.boot.autoconfigure.cache.EhCacheCacheConfiguration. Reason(s): java.lang.NoClassDefFoundError: net/sf/ehcache/CacheManager
Warning: Could not register complete reflection metadata for org.springframework.boot.autoconfigure.sql.init.R2dbcInitializationConfiguration. Reason(s): java.lang.NoClassDefFoundError: io/r2dbc/spi/ConnectionFactory
Warning: Could not register complete reflection metadata for org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration. Reason(s): java.lang.NoClassDefFoundError: org/springframework/data/redis/connection/RedisConnectionFactory
Warning: Could not register complete reflection metadata for org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration. Reason(s): java.lang.NoClassDefFoundError: javax/cache/CacheManager
Warning: Could not register complete reflection metadata for org.springframework.cloud.stream.binder.kafka.config.KafkaBinderHealthIndicatorConfiguration. Reason(s): java.lang.NoClassDefFoundError: org/springframework/boot/actuate/health/HealthIndicator
Warning: Could not register complete reflection metadata for org.springframework.boot.autoconfigure.cache.HazelcastCacheConfiguration. Reason(s): java.lang.NoClassDefFoundError: com/hazelcast/core/HazelcastInstance
Warning: Could not register complete reflection metadata for org.springframework.boot.autoconfigure.cache.RedisCacheConfiguration. Reason(s): java.lang.NoClassDefFoundError: org/springframework/data/redis/serializer/RedisSerializer
Warning: Could not register complete reflection metadata for org.springframework.integration.json.JsonPathUtils. Reason(s): java.lang.NoClassDefFoundError: [Lcom/jayway/jsonpath/Predicate;
Warning: Could not register complete reflection metadata for org.springframework.boot.autoconfigure.cache.CaffeineCacheConfiguration. Reason(s): java.lang.NoClassDefFoundError: org/springframework/cache/caffeine/CaffeineCacheManager
Warning: Could not register complete reflection metadata for org.springframework.boot.autoconfigure.cache.CouchbaseCacheConfiguration. Reason(s): java.lang.NoClassDefFoundError: org/springframework/data/couchbase/CouchbaseClientFactory
Warning: Could not register complete reflection metadata for org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator. Reason(s): java.lang.NoClassDefFoundError: org/aspectj/util/PartialOrder$PartialComparable
Warning: Could not register complete reflection metadata for org.springframework.cloud.stream.micrometer.DestinationPublishingMetricsAutoConfiguration. Reason(s): java.lang.NoClassDefFoundError: io/micrometer/core/instrument/step/StepRegistryConfig
Warning: Could not register complete reflection metadata for org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator. Reason(s): java.lang.NoClassDefFoundError: org/aspectj/util/PartialOrder$PartialComparable
Warning: Could not register complete reflection metadata for org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration. Reason(s): java.lang.NoClassDefFoundError: org/neo4j/driver/Driver
Warning: Could not register complete reflection metadata for org.springframework.boot.autoconfigure.cache.InfinispanCacheConfiguration. Reason(s): java.lang.NoClassDefFoundError: org/infinispan/manager/EmbeddedCacheManager
[kafka-sasl:6976]     (clinit):   3,727.81 ms,  5.93 GB
[kafka-sasl:6976]   (typeflow):  20,230.23 ms,  5.93 GB
[kafka-sasl:6976]    (objects):  87,117.86 ms,  5.93 GB
[kafka-sasl:6976]   (features):  19,444.48 ms,  5.93 GB
[kafka-sasl:6976]     analysis: 135,589.99 ms,  5.93 GB
[kafka-sasl:6976]     universe:   8,395.86 ms,  6.16 GB
[kafka-sasl:6976]      (parse):  15,054.85 ms,  5.99 GB
[kafka-sasl:6976]     (inline):  16,029.71 ms,  5.99 GB
[kafka-sasl:6976]    (compile):  54,547.78 ms,  5.80 GB
[kafka-sasl:6976]      compile:  93,073.56 ms,  5.80 GB
[kafka-sasl:6976]        image:  10,320.79 ms,  5.87 GB
[kafka-sasl:6976]        write:   2,287.32 ms,  5.87 GB
[kafka-sasl:6976]      [total]: 261,829.27 ms,  5.87 GB
# Printing build artifacts to: /Users/user/IdeaProjectsHans/kafka-sasl/target/kafka-sasl.build_artifacts.txt
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:54 min
[INFO] Finished at: 2021-12-06T16:33:14+09:00
[INFO] ------------------------------------------------------------------------

Build success but when i send a message, I got error.

2021-12-06 17:25:33.554  INFO 20158 --- [           main] o.a.k.clients.producer.ProducerConfig    : ProducerConfig values: 
        acks = 1
        batch.size = 16384
        bootstrap.servers = [XXXXXX]
        buffer.memory = 33554432
        client.dns.lookup = use_all_dns_ips
        client.id = producer-1
        compression.type = gzip
        connections.max.idle.ms = 540000
        delivery.timeout.ms = 120000
        enable.idempotence = false
        interceptor.classes = []
        internal.auto.downgrade.txn.commit = true
        key.serializer = class org.apache.kafka.common.serialization.StringSerializer
        linger.ms = 300
        max.block.ms = 60000
        max.in.flight.requests.per.connection = 5
        max.request.size = 5242880
        metadata.max.age.ms = 300000
        metadata.max.idle.ms = 300000
        metric.reporters = []
        metrics.num.samples = 2
        metrics.recording.level = INFO
        metrics.sample.window.ms = 30000
        partitioner.class = class org.apache.kafka.clients.producer.internals.DefaultPartitioner
        receive.buffer.bytes = 32768
        reconnect.backoff.max.ms = 1000
        reconnect.backoff.ms = 50
        request.timeout.ms = 30000
        retries = 2147483647
        retry.backoff.ms = 100
        sasl.client.callback.handler.class = null
        sasl.jaas.config = [hidden]
        sasl.kerberos.kinit.cmd = /usr/bin/kinit
        sasl.kerberos.min.time.before.relogin = 60000
        sasl.kerberos.service.name = null
        sasl.kerberos.ticket.renew.jitter = 0.05
        sasl.kerberos.ticket.renew.window.factor = 0.8
        sasl.login.callback.handler.class = null
        sasl.login.class = null
        sasl.login.refresh.buffer.seconds = 300
        sasl.login.refresh.min.period.seconds = 60
        sasl.login.refresh.window.factor = 0.8
        sasl.login.refresh.window.jitter = 0.05
        sasl.mechanism = SCRAM-SHA-512
        security.protocol = SASL_SSL
        security.providers = null
        send.buffer.bytes = 131072
        socket.connection.setup.timeout.max.ms = 127000
        socket.connection.setup.timeout.ms = 10000
        ssl.cipher.suites = null
        ssl.enabled.protocols = [TLSv1.2, TLSv1.3]
        ssl.endpoint.identification.algorithm = 
        ssl.engine.factory.class = null
        ssl.key.password = null
        ssl.keymanager.algorithm = SunX509
        ssl.keystore.certificate.chain = null
        ssl.keystore.key = null
        ssl.keystore.location = null
        ssl.keystore.password = null
        ssl.keystore.type = JKS
        ssl.protocol = TLSv1.3
        ssl.provider = null
        ssl.secure.random.implementation = null
        ssl.trustmanager.algorithm = PKIX
        ssl.truststore.certificates = null
        ssl.truststore.location = XXXXX.jks
        ssl.truststore.password = [hidden]
        ssl.truststore.type = JKS
        transaction.timeout.ms = 60000
        transactional.id = null
        value.serializer = class org.apache.kafka.common.serialization.StringSerializer

2021-12-06 17:25:33.712  INFO 20158 --- [           main] o.a.k.c.s.authenticator.AbstractLogin    : Successfully logged in.
2021-12-06 17:25:33.717  INFO 20158 --- [           main] o.a.kafka.common.utils.AppInfoParser     : Kafka version: 2.7.1
2021-12-06 17:25:33.717  INFO 20158 --- [           main] o.a.kafka.common.utils.AppInfoParser     : Kafka commitId: 61dbce85d0d41457
2021-12-06 17:25:33.717  INFO 20158 --- [           main] o.a.kafka.common.utils.AppInfoParser     : Kafka startTimeMs: 1638779133717
2021-12-06 17:25:33.948  WARN 20158 --- [ad | producer-1] o.apache.kafka.common.network.Selector   : [Producer clientId=producer-1] Unexpected error from XXXXXX; closing connection

java.lang.NullPointerException: null
        at java.util.regex.Matcher.getTextLength(Matcher.java:1770) ~[na:na]
        at java.util.regex.Matcher.reset(Matcher.java:416) ~[na:na]
        at java.util.regex.Matcher.<init>(Matcher.java:253) ~[na:na]
        at java.util.regex.Pattern.matcher(Pattern.java:1133) ~[na:na]
        at org.apache.kafka.common.security.scram.internals.ScramFormatter.saslName(ScramFormatter.java:106) ~[kafka-sasl:na]
        at org.apache.kafka.common.security.scram.internals.ScramSaslClient.evaluateChallenge(ScramSaslClient.java:115) ~[kafka-sasl:na]
        at org.apache.kafka.common.security.authenticator.SaslClientAuthenticator.lambda$createSaslToken$1(SaslClientAuthenticator.java:524) ~[kafka-sasl:na]
        at java.security.AccessController.doPrivileged(AccessController.java:150) ~[na:na]
        at javax.security.auth.Subject.doAs(Subject.java:423) ~[na:na]
        at org.apache.kafka.common.security.authenticator.SaslClientAuthenticator.createSaslToken(SaslClientAuthenticator.java:524) ~[kafka-sasl:na]
        at org.apache.kafka.common.security.authenticator.SaslClientAuthenticator.sendSaslClientToken(SaslClientAuthenticator.java:431) ~[kafka-sasl:na]
        at org.apache.kafka.common.security.authenticator.SaslClientAuthenticator.sendInitialToken(SaslClientAuthenticator.java:330) ~[kafka-sasl:na]
        at org.apache.kafka.common.security.authenticator.SaslClientAuthenticator.authenticate(SaslClientAuthenticator.java:271) ~[kafka-sasl:na]
        at org.apache.kafka.common.network.KafkaChannel.prepare(KafkaChannel.java:176) ~[na:na]
        at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:543) ~[na:na]
        at org.apache.kafka.common.network.Selector.poll(Selector.java:481) ~[na:na]
        at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:563) ~[na:na]
        at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:325) ~[na:na]
        at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:240) ~[na:na]
        at java.lang.Thread.run(Thread.java:829) ~[na:na]
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:596) ~[na:na]
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192) ~[na:na]

2021-12-06 17:25:33.966  WARN 20158 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Connection to node -2 (XXXXX) terminated during authentication. This may happen due to any of the following reasons: (1) Authentication failed due to invalid credentials with brokers older than 1.0.0, (2) Firewall blocking Kafka TLS traffic (eg it may only allow HTTPS traffic), (3) Transient network issue.
2021-12-06 17:25:33.973  WARN 20158 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Bootstrap broker XXXXXX (id: -2 rack: null) disconnected
2021-12-06 17:25:34.325  WARN 20158 --- [ad | producer-1] o.apache.kafka.common.network.Selector   : [Producer clientId=producer-1] Unexpected error from XXXXXXX closing connection
munishchouhan commented 2 years ago

@han1448 thanks for reporting the issue, we will check it out and get back to you

munishchouhan commented 2 years ago

@han1448 please share the steps to start your application and send message to get the reported error

han1448 commented 2 years ago

@mcraj017

https://github.com/han1448/kafka-sasl-native

Here is my test repo and I wrote README.md.

However, for actual testing, you need a broker with kafka topics and sasl authentication settings for testing.

It seems that the username of ScramLoginModule cannot be obtained from the kafka sasl configuration rather than the issue of sending and receiving messages.

rodrigar-mx commented 2 years ago

Hi @han1448. I will try first to reproduce the issue locally. If you have a Dockerfile for launching kafka that meets the config of your app, it would be great. Any other questions or updates, I will let you know.

han1448 commented 2 years ago

Hi. @rodrigar-mx I've updated my repo and added kafka docker. In this case I did not configure ssl, only sasl authentication was added. The error log is a little different from before, but not sure if the error is caused by the same authentication issue.

This scenario also works fine without native image.

Starting kafka

$ git clone https://github.com/han1448/kafka-docker.git
$ git checkout seunghyeon/add-jaas

$ docker-compose -f docker-compose-single-broker.yml up 

Create Topic

Required to install kafka client in local

$ ./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testtopic1

Created topic testtopic1.

Getting application & Build

$ git clone https://github.com/han1448/kafka-sasl-native
$ git checkout  seunghyeon/test
$ ./mvnw -Pnative -DskipTests clean package

Starting application

target/kafka-sasl

Error logs

2022-01-12 15:20:24.434  INFO 8942 --- [ad | producer-1] o.a.k.common.network.SaslChannelBuilder  : [Producer clientId=producer-1] Failed to create channel due to 

org.apache.kafka.common.errors.SaslAuthenticationException: Failed to configure SaslClientAuthenticator
Caused by: org.apache.kafka.common.errors.SaslAuthenticationException: Failed to create SaslClient with mechanism PLAIN

2022-01-12 15:20:24.435  WARN 8942 --- [ad | producer-1] org.apache.kafka.clients.NetworkClient   : [Producer clientId=producer-1] Error connecting to node localhost:9092 (id: -1 rack: null)

java.io.IOException: Channel could not be created for socket java.nio.channels.SocketChannel[closed]
        at org.apache.kafka.common.network.Selector.buildAndAttachKafkaChannel(Selector.java:348) ~[na:na]
        at org.apache.kafka.common.network.Selector.registerChannel(Selector.java:329) ~[na:na]
        at org.apache.kafka.common.network.Selector.connect(Selector.java:256) ~[na:na]
        at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:1006) ~[na:na]
        at org.apache.kafka.clients.NetworkClient.access$600(NetworkClient.java:75) ~[na:na]
        at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:1177) ~[na:na]
        at org.apache.kafka.clients.NetworkClient$DefaultMetadataUpdater.maybeUpdate(NetworkClient.java:1065) ~[na:na]
        at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:561) ~[na:na]
        at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:325) ~[na:na]
        at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:240) ~[na:na]
        at java.lang.Thread.run(Thread.java:829) ~[na:na]
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:596) ~[na:na]
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192) ~[na:na]
Caused by: org.apache.kafka.common.KafkaException: org.apache.kafka.common.errors.SaslAuthenticationException: Failed to configure SaslClientAuthenticator
        at org.apache.kafka.common.network.SaslChannelBuilder.buildChannel(SaslChannelBuilder.java:228) ~[na:na]
        at org.apache.kafka.common.network.Selector.buildAndAttachKafkaChannel(Selector.java:338) ~[na:na]
        ... 12 common frames omitted

Success case

This log is a log that does not use native image and works fine.

2022-01-12 15:25:52.570  INFO 12635 --- [           main] o.a.k.c.s.authenticator.AbstractLogin    : Successfully logged in.
2022-01-12 15:25:52.598  INFO 12635 --- [           main] o.a.kafka.common.utils.AppInfoParser     : Kafka version: 2.7.1
2022-01-12 15:25:52.599  INFO 12635 --- [           main] o.a.kafka.common.utils.AppInfoParser     : Kafka commitId: 61dbce85d0d41457
2022-01-12 15:25:52.599  INFO 12635 --- [           main] o.a.kafka.common.utils.AppInfoParser     : Kafka startTimeMs: 1641968752597
2022-01-12 15:25:52.906  INFO 12635 --- [ad | producer-1] org.apache.kafka.clients.Metadata        : [Producer clientId=producer-1] Cluster ID: LCUnyePpSUKkAupT3uCuOw
success
2022-01-12 15:25:53.058  INFO 12635 --- [           main] c.e.kafkasasl.KafkaSaslApplicationKt     : Started KafkaSaslApplicationKt in 1.771 seconds (JVM running for 2.412)
2022-01-12 15:25:53.064  INFO 12635 --- [ionShutdownHook] o.a.k.clients.producer.KafkaProducer     : [Producer clientId=producer-1] Closing the Kafka producer with timeoutMillis = 30000 ms.
2022-01-12 15:25:53.071  INFO 12635 --- [ionShutdownHook] org.apache.kafka.common.metrics.Metrics  : Metrics scheduler closed
2022-01-12 15:25:53.071  INFO 12635 --- [ionShutdownHook] org.apache.kafka.common.metrics.Metrics  : Closing reporter org.apache.kafka.common.metrics.JmxReporter
2022-01-12 15:25:53.072  INFO 12635 --- [ionShutdownHook] org.apache.kafka.common.metrics.Metrics  : Metrics reporters closed
2022-01-12 15:25:53.072  INFO 12635 --- [ionShutdownHook] o.a.kafka.common.utils.AppInfoParser     : App info kafka.producer for producer-1 unregistered

Process finished with exit code 0

And also without sasl, native-image producer works find too. Thank you in advance.

a-inacio commented 2 years ago

Hi there,

Also having an issue with Kafka SASL authentication, however having a different error output from @han1448's and was about to open an issue when stumbled into this one. Similar use case for spring native, but with java 17 (should not be that different under the hood) and I'm using a newer version of Spring Boot (2.6.2 vs 2.5.6).

https://github.com/a-inacio/spring-native-kafka/

I believe it is related to this issue, so I'm commenting and leaving my own repo here.

Can be tried by running docker compose up, provided you have your settings first on a local.env file (details in the readme). Thanks to @han1448 for already providing the hints to setup a simple broker with SASL, have the same requirements. My docker file omits a runtime layer (since I was not sure if I could be missing out something from the compilation step, nevertheless, no differences here).

Also took some time to experiment with the extra Native Hints I found on Han's repo but had no effect on my error message.

Additionally, checked this topic for Quarkus where it seems to be a connection and even references Graal, might be worth having a look at this @rodrigar-mx: https://github.com/quarkusio/quarkus/issues/8168

Maybe @rodrigar-mx you can use the same credentials and try both our applications at the same time or use my docker file to dockerize quickly @han1448's one (I'm sure I'll benefit from your effort either way).

Sorry if I'm getting out of topic and thank you all in advance!

han1448 commented 2 years ago

Thank you for your comment @a-inacio. It looks the same issue in my comment above.

@rodrigar-mx. It shows different error using security protocol SASL_PLAINTEXT and SASL_SSL The first NullPointerException is when SASL_SSL is used, and the situation tested in the comment above is when SASL_PLAINTEXT is used.

Using truststore jks file SASL_SSL