8000 java.lang.ExceptionInInitializerError when using GenericSerde · Issue #810 · sksamuel/avro4s · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

java.lang.ExceptionInInitializerError when using GenericSerde #810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ayoub-benali opened this issue Nov 29, 2023 · 1 comment
Open

java.lang.ExceptionInInitializerError when using GenericSerde #810

ayoub-benali opened this issue Nov 29, 2023 · 1 comment

Comments

@ayoub-benali
Copy link
ayoub-benali commented Nov 29, 2023

Hello,

I generated case classes from an Avro schema file using sbt-avrohugger and I want to use avro4s for generating a kafka Serde because io.confluent.kafka.streams.serdes.avro.SpecificAvroSerde doesn't work with classes that include Shapeless classes.

Initially I tried this:

import org.apache.kafka.common.serialization.Serde
import com.sksamuel.avro4s.kafka.GenericSerde
import com.sksamuel.avro4s.BinaryFormat
import scala.collection.JavaConverters._

implicit val inputSerde: Serde[MyClass] = new GenericSerde[MyClass](BinaryFormat)

val serdeConfig = Map("schema.registry.url" -> "SOME_URL").asJava
inputSerde.configure(serdeConfig, false)

MyClass has a lot of nested classes and I got this error during compilation:

[error] Error while emitting MyClass$
[error] Method too large: MyClass$.<init> ()V

Then I tried invoking SchemaFor like this:

import org.apache.kafka.common.serialization.Serde
import com.sksamuel.avro4s.kafka.GenericSerde
import com.sksamuel.avro4s.BinaryFormat
import com.sksamuel.avro4s.SchemaFor
import scala.collection.JavaConverters._

implicit val myClassSchemaFor: SchemaFor[MyClass] = SchemaFor[MyClass]
implicit val inputSerde: Serde[MyClass] = new GenericSerde[MyClass](BinaryFormat)

val serdeConfig = Map("schema.registry.url" -> "SOME_URL").asJava
inputSerde.configure(serdeConfig, false)

But then I got this error during runtime:

[error]   caused by java.lang.ExceptionInInitializerError
[error]   caused by java.lang.NullPointerException
[error]   sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error]   sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[error]   sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error]   java.lang.reflect.Constructor.newInstance(Constructor.java:423)
....

[error]
[error]   CAUSED BY java.lang.ExceptionInInitializerError
[error]   com.sksamuel.avro4s.AvroSchema$.apply(AvroSchema.scala:20)
[error]   com.sksamuel.avro4s.kafka.GenericSerde.<init>(GenericSerde.scala:21)
...

Any idea how to solve or debug this problem ?

These are the main dependencies:

"org.apache.avro"          % "avro"                   % "1.10.2"
"com.sksamuel.avro4s" %% "avro4s-core"  % "4.1.1",
"com.sksamuel.avro4s" %% "avro4s-kafka" % "4.1.1"
"io.confluent"                   % "kafka-streams-avro-serde" % "5.4.5"
"com.chuusai"                  %% "shapeless"     % "2.3.3"

sbt-avrohugger version 2.8.0
scala version: 2.12.18
Thanks

@ayoub-benali ayoub-benali changed the title Method too large when using GenericSerde java.lang.ExceptionInInitializerError when using GenericSerde Nov 29, 2023
Copy link
stale bot commented Apr 26, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the abandoned label Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0