Check out our Angular Book Series.

Why won't Jersey work on JDK 9?

I've been experimenting with writing REST Services in Java. A ton of clients have used Java to power their backend's over the years, but I never created a REST Service environment from scratch myself. I decided to tackle it during the holiday time and educate myself. I try to focus on front end programming technologies, but knowing about the backend is beneficial.

I decided to use Jersey to build out REST Services in Java and the road has been rocky.

I have a Maven project setup to use Tomcat 8.5 and Java 9.01. Unfortunately, I kept seeing a lot of errors like this in the Java console:

java.lang.IllegalArgumentException: Errors were discovered while reifying SystemDescriptor(
    at org.jvnet.hk2.internal.SystemDescriptor.reify(
    at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor

etc.. etc..

or this:

java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
    at org.glassfish.hk2.utilities.cache.LRUHybridCache.compute(
    at org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl.getAllMethods(
    at org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl.getPreDestroyMethod(
    at org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl.access$400(
    at org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl$2.compute(
    at org.glassfish.hk2.utilities.reflection.internal.ClassReflectionHelperImpl$2.compute(
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$OriginThreadAwareFuture$
    at java.base/
    at org.glassfish.hk2.utilities.cache.LRUHybridCache$
    at org.glassfish.hk2.utilities.cache.LRUHybridCache.compute(

They went on and on. Basically, some libraries that are required by Jersey are no longer included as part of the Java 9 SDK. They were there in Java 8, but were removed. These errors exist because the libraries cannot be found.

The trick to remove these errors is to load these libraries using Maven. Find the pom.xml that builds your project and find the dependencies section. It will probably look something like this:

<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
<!-- uncomment this to get JSON support


We need to add back in the missing dependencies. There are two libraries that were required:


Relaunch your Tomcat instance and you are good to go. No errors and your Jersey services should work without issue.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
All Content Copyright 2005, 2006, 2007, 2008, 2009 Jeffry Houser. May not be reused without permission
BlogCFC was created by Raymond Camden. This blog is running version