Support java 9 projects
See original GitHub issueWhen https://github.com/jwtk/jjwt/issues/259 was fixed, it only verified that jjwt itself can be built with Java 9 (but targeting an older version of java). It did not address the problem of using jjwt in a project that is targeting Java 9.
You can see the problem in jjwt by modifying the <jdk.version>
to 1.9 and trying to build:
diff --git a/pom.xml b/pom.xml
index 1c34c5b..02e3f5a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,7 +81,7 @@
<maven.jar.version>3.0.2</maven.jar.version>
<maven.compiler.version>3.6.1</maven.compiler.version>
- <jdk.version>1.7</jdk.version>
+ <jdk.version>1.9</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<buildNumber>${user.name}-${maven.build.timestamp}</buildNumber>
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T03:58:13-04:00)
Maven home: /Users/ryan/.m2/wrapper/dists/apache-maven-3.5.2-bin/28qa8v9e2mq69covern8vmdkj0/apache-maven-3.5.2
Java version: 9.0.1, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.1", arch: "x86_64", family: "mac"
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ jjwt ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 81 source files to /Users/ryan/projects/java/jjwt/target/classes
[INFO] /Users/ryan/projects/java/jjwt/src/main/java/io/jsonwebtoken/lang/Classes.java: Some input files use or override a deprecated API.
[INFO] /Users/ryan/projects/java/jjwt/src/main/java/io/jsonwebtoken/lang/Classes.java: Recompile with -Xlint:deprecation for details.
[INFO] /Users/ryan/projects/java/jjwt/src/main/java/io/jsonwebtoken/lang/RuntimeEnvironment.java: Some input files use unchecked or unsafe operations.
[INFO] /Users/ryan/projects/java/jjwt/src/main/java/io/jsonwebtoken/lang/RuntimeEnvironment.java: Recompile with -Xlint:unchecked for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/ryan/projects/java/jjwt/src/main/java/io/jsonwebtoken/impl/Base64Codec.java:[21,25] package javax.xml.bind is not visible
(package javax.xml.bind is declared in module java.xml.bind, which is not in the module graph)
[ERROR] /Users/ryan/projects/java/jjwt/src/main/java/io/jsonwebtoken/impl/Base64Codec.java:[26,25] package javax.xml.bind is not visible
(package javax.xml.bind is declared in module java.xml.bind, which is not in the module graph)
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.205 s
[INFO] Finished at: 2017-11-18T14:57:44-05:00
[INFO] Final Memory: 26M/86M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project jjwt: Compilation failure: Compilation failure:
[ERROR] /Users/ryan/projects/java/jjwt/src/main/java/io/jsonwebtoken/impl/Base64Codec.java:[21,25] package javax.xml.bind is not visible
[ERROR] (package javax.xml.bind is declared in module java.xml.bind, which is not in the module graph)
[ERROR] /Users/ryan/projects/java/jjwt/src/main/java/io/jsonwebtoken/impl/Base64Codec.java:[26,25] package javax.xml.bind is not visible
[ERROR] (package javax.xml.bind is declared in module java.xml.bind, which is not in the module graph)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I have also created a project that uses jjwt and shows the problem referenced in #259: https://github.com/RyanBard/jjwt-consumer-example
The problem is that Java 9 has deprecated jaxb and it requires extra flags to include that module. If I understand correctly, jaxb will probably be completely removed in Java 10, so it seems like the best solution is to explicitly depend on jaxb. This should make it easier for jjwt to target multiple versions of java without having to build multiple artifacts with different classifiers.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:10 (6 by maintainers)
Top GitHub Comments
@Spenhouet
You can add an explicit dependency on jaxb-api to your project until jjwt adds the dependency or removes the usage of jaxb classes:
https://github.com/jwtk/jjwt/pull/283/files
Closing as a duplicate of #333. Work will be tracked via that issue and we hope to have that released asap in the coming days.