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

Incompatibility with JDK 9 (by of AWS SDK) #58

Open
michaelahlers opened this issue Oct 15, 2017 · 9 comments
Open

Incompatibility with JDK 9 (by of AWS SDK) #58

michaelahlers opened this issue Oct 15, 2017 · 9 comments

Comments

@michaelahlers
Copy link

michaelahlers commented Oct 15, 2017

This isn't a bug, per se. More of a tip for anyone using Java 9 who's encountered this error:

[info] 	delivering ivy file to /Users/myuser/Projects/my-project/target/scala-2.12/ivy-0.0.1-SNAPSHOT.xml
[error] java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
[error] 	at com.amazonaws.util.Md5Utils.md5AsBase64(Md5Utils.java:104)
[error] 	at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1636)
[error] 	at ohnosequences.ivy.S3Repository.put(S3Repository.java:248)
…
[error] Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
[error] 	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
[error] 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563)
[error] 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
[error] 	at com.amazonaws.util.Md5Utils.md5AsBase64(Md5Utils.java:104)
[error] 	at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1636)
[error] 	at ohnosequences.ivy.S3Repository.put(S3Repository.java:248)
…

(Truncated and redacted.)

It's caused aws/aws-sdk-java#1092 and can be easily worked-around thanks to a tip by @jayeshja. In short, passing --add-modules=java.xml.bind,java.activation to Java resolves it.

Two ways this is accomplished with SBT are:

  1. Adding the flag to an .sbtopts file in your project's root with:
    -J--add-modules=java.xml.bind,java.activation
    
  2. Appending the SBT_OPTS environment variable with:
    --add-modules=java.xml.bind,java.activation
    
@laughedelic
Copy link
Contributor

@michaelahlers Thanks for providing the information! I will add a link to this issue in the readme.

ScalaWilliam added a commit to ScalaWilliam/aptgit that referenced this issue Mar 10, 2018
Got: `java.lang.NoClassDefFoundError: javax/activation/DataSource` which is why I added `.jvmopts` file and some options in `aptgit.sbt`. Based on:
- ohnosequences/sbt-s3-resolver#58
- playframework/playframework#7879 (comment)
@Tvaroh
Copy link

Tvaroh commented Nov 27, 2018

This doesn't work for JDK 11 and requires adding jaxb-api dependency manually.

@pjfanning
Copy link

@Tvaroh would you be able to describe the workaround you did for JDK 11?

@Tvaroh
Copy link

Tvaroh commented Feb 6, 2019

@pjfanning actually it didn't work for me. So my "workaround" is export JAVA_HOME=`/usr/libexec/java_home -v 1.8.

@schneist
Copy link

@Tvaroh @pjfanning

importing
"javax.xml.bind" % "jaxb-api" % "2.3.0", "com.sun.xml.bind" % "jaxb-ri" % "2.3.0"

in project/build.sbt worked for me.

@Tvaroh
Copy link

Tvaroh commented May 12, 2019

@schneist does it work for multi-module builds?

@schneist
Copy link

sorry I ran into an issue with an aws library being outdated later, and did not continue to investigate. But the ClassNotFoundException was gone for a multi-mode build too.

@franchev
Copy link

Does this work at all for java-11, Adding dependencies as below did not work for me.

<dependencies>
 <dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-core</artifactId>
    <version>2.3.0.1</version>
  </dependency>
  <dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.1</version>
  </dependency>
  <dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.3.1</version>
    </dependency>
</dependencies>

@pjfanning
Copy link

@franchev your snippet is not sbt - it is maven

see #58 (comment)

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

No branches or pull requests

6 participants