jersey
jersey copied to clipboard
Jersey missing explicit dependency on javax.annotation
When using Jersey client under Java 9 I get:
java.lang.NoClassDefFoundError: javax/annotation/Priority
at org.glassfish.jersey.model.internal.RankedProvider.computeRank(RankedProvider.java:111)
at org.glassfish.jersey.model.internal.RankedProvider.<init>(RankedProvider.java:72)
at org.glassfish.jersey.internal.inject.Injections.lookupService(Injections.java:113)
at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:97)
at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:68)
at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:432)
at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:341)
at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:826)
at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285)
at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:143)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:112)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:108)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:99)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:445)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:351)
My dependencies are:
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jetty-connector</artifactId>
<version>2.26</version>
</dependency>
Jersey should depend on javax.annotation
instead of assuming it will be provided.
See https://github.com/jersey/jersey/issues/3712 for a related discussion.
I think that adding this dependency will lead to many problems for JDK8 users. Why don't you just add this dependency to your pom?
@chkal I tried but never did manage to get this working. If Jersey 2.26 is usable on JDK 9 and 10, the steps should be documented somewhere. I suspect some actual code changes will be required, aside from documentation.
AFAIK the Java EE related packages aren't visible to your application by default. Perhaps you could have a look here to see if this helps:
https://blog.codefx.org/java/java-9-migration-guide/#Dependencies-On-Java-EE-Modules