Skip to content
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

NoClassDefFoundError: javax/xml/bind/DatatypeConverter with amazon-kinesis-producer 0.14.13 on JDK 11 #452

Open
vsadokhin opened this issue Oct 4, 2022 · 8 comments

Comments

@vsadokhin
Copy link

Hello

I experience NoClassDefFoundError: javax/xml/bind/DatatypeConverter during build/tests if amazon-kinesis-producer version bumped from 0.14.12 to 0.14.13. The stacktrace says:

Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
	at com.amazonaws.services.kinesis.producer.HashedFileCopier.copyFileFrom(HashedFileCopier.java:56)
	at com.amazonaws.services.kinesis.producer.KinesisProducer.extractBinaries(KinesisProducer.java:1025)
	at com.amazonaws.services.kinesis.producer.KinesisProducer.<init>(KinesisProducer.java:298)
	at ...

According to maven dependencies 0.14.13 brings jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0 and my IDE shows that it has DatatypeConverter but from jakarta.xml.bind package. However, HashedFileCopier from amazon-kinesis-producer:0.14.13 imports javax.xml.bind.DatatypeConverter and that one indeed missed.

Please, find my questions below:
Is it correct that HashedFileCopier refers to javax.xml.bind.DatatypeConverter?
Will it be changed / fixed in the feature releases of amazon-kinesis-producer?
What is the recommended way to bypass the issue now? (I guess provide a dependency with javax.xml.bind.DatatypeConverter)

Thank you in advance!

King Regards,
Vasiliy

@vsadokhin
Copy link
Author

c2adf14

Looks relevant

@MeesvanStraten
Copy link

any idea how to fix this error? running java 17 and have the same problem with Kinesis producer.

@superfive666
Copy link

superfive666 commented Oct 25, 2022

@MeesvanStraten you can try building the producer jar from local changing:
import javax.xml.bind.DatatypeConverter; to import jakarta.xml.bind.DatatypeConverter;
And replace the jar in your maven m2 folder.

Alternatively,
try adding in the following dependencies in the pom.xml?

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>

@lc-nyovchev
Copy link

@superfive666 if that's the local fix, maybe we can aim the official build/maven artifact to incorporate those changes?

@MeesvanStraten does building the producer yourself with the suggestion fix it for you locally?

@MeesvanStraten
Copy link

@lc-nyovchev Adding the javax.xml.bind package myself works. It has something to do with the package not being included from Java 9.

This stack overflow helped me understanding better

@zengyu714
Copy link
Contributor

Hello folks, this issue should be fixed by this commit: 7e6203d

@kbos-work
Copy link

kbos-work commented Jan 4, 2023

@zengyu714 hi, I understand the fix in terms of supporting older Java. If I look at the code and why it is used it is basically (ignoring the sample app) for converting binary to hex. Not sure how you guys are on dependencies, but perhaps depending on https://commons.apache.org/proper/commons-codec/archives/1.15/apidocs/index.html encodeHex which to my believe should bring the same functionality would remove the need for depending on xml.bind all together

@kbos-work
Copy link

or another alternative, because I am also not a fan to depend just for a single thing on some library is to have this logic within the repository. Looking at the original source of printHexBinary (https://github.com/javaee/jaxb-spec/blob/master/jaxb-api/src/main/java/javax/xml/bind/DatatypeConverterImpl.java) it doesn't seem to dramatic to support within the repo with proper tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants