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

Base64 static initialization fails when jaxb-core not in classpath with jaxb-impl >= 2.2.11 #1863

Closed
akhaku opened this issue Jan 4, 2019 · 6 comments
Labels
investigating This issue is being investigated and/or work is in progress to resolve the issue.

Comments

@akhaku
Copy link

akhaku commented Jan 4, 2019

#1428 noted that certain classes were moved from jaxb-impl to jaxb-core, which caused Base64 to fail to statically initialize. ba4a6a4 updated the static initializer to attempt to not fail if jaxb was not enabled in Java 9. However, in Java8, if you have jaxb-impl on your classpath but not jaxb-core, JAXBContext.newInstance() fails with a NoClassDefFoundError (which wraps a ClassNotFoundException), meaning that the exception is not caught and Base64 fails to initialize.

screen shot 2019-01-04 at 2 56 21 pm

@akhaku akhaku changed the title Base64 static initialization fails when jaxb-core not in classpath Base64 static initialization fails when jaxb-core not in classpath with jaxb-impl >= 2.2.11 Jan 4, 2019
akhaku added a commit to akhaku/aws-sdk-java that referenced this issue Jan 4, 2019
Not having certain classes on the classpath results in a
NoClassDefFoundError (that wraps a ClassNotFoundException)
which causes static initialization failure. Protect against
that by catching Throwable instead of Exception.
@varunnvs92
Copy link
Contributor

Isn't jaxb-core required to properly initialize JAXBContext?
Can you clarify whats the expected behavior should be?

@varunnvs92 varunnvs92 added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Jan 8, 2019
@akhaku
Copy link
Author

akhaku commented Jan 8, 2019

As of jaxb-impl >= 2.2.11, yes. It looks like the intention of the static block in Base64 is to use jaxb if possible, but fall back to the SDK impl if it's not available. Not catching the NoClassDefFoundError makes that second bit break - the expected behaviour in that case is to bail out and use the SDK impl. With jaxb-impl < 2.2.11, we don't get the NoClassDefFoundError since only jaxb-impl is needed and not jaxb-core. You're right that we should be including the jaxb-core jar ourselves, but Base64 probably shouldn't fail to initialize without that jar.

@varunnvs92
Copy link
Contributor

Got it. Catching Throwable instead of Exception should fix the issue. I will make the change.

@akhaku
Copy link
Author

akhaku commented Jan 16, 2019

Thanks! I opened #1864 to make that change - might be simpler to hit merge on that guy?

@varunnvs92
Copy link
Contributor

Fixed in v1.11.485. Thanks for reporting the issue and PR.

tpunder added a commit to tpunder/fm-sbt-s3-resolver that referenced this issue Mar 4, 2019
@brunoeufrasio
Copy link

Corrigido em v1.11.485. Obrigado por relatar o problema e PR.

Atualizando pra essa versão resolveu pra mim tambem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating This issue is being investigated and/or work is in progress to resolve the issue.
Projects
None yet
Development

No branches or pull requests

3 participants