question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support java 9 projects

See original GitHub issue

When 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
RyanBardcommented, Nov 20, 2017

@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

0reactions
lhazlewoodcommented, Jul 5, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Guide to Java 9 Modularity - Baeldung
Learn the essentials of building and using modules in Java 9. Start down the path of modularizing your code today.
Read more >
Understanding Java 9 Modules - Oracle
In this article, I introduce the Java 9 Platform Module System (JPMS), the most important new software engineering technology in Java since its...
Read more >
Java 9+ modularity: The difficulties and pitfalls of migrating ...
By looking at compatibility, migration issues, and techniques, explore the new APIs and tools, changes, deletions, and deprecations in Java ...
Read more >
Java 9 Modules | DigitalOcean
The main goal of Java 9 Module System is to support Modular Programming in Java. We will discuss on “What is a Module...
Read more >
Embracing Java 9 and beyond with Eclipse JDT
Quarterly releases of the Eclipse IDE in March, June, September, and December will help provide a release with a new version of Java...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found