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.

JAX-RS annotation on interface

See original GitHub issue

Hello, I am working on an 1.0 implementation where I am using Jersey for Jax-rs implementation and Weld for CDI, but I have encountered a problem:

Jersey does not support JaxRs annotations on interfaces (which is by specification jsr370-2.1 chapter 3.6) if they are not implemented. Therefore when I try to run example I get

org.jboss.weld.exceptions.IllegalArgumentException: WELD-001508: Cannot create an InjectionTarget from 
[EnhancedAnnotatedTypeImpl] public abstract interface @RegisterRestClient @Produces 
@Dependent @Consumes @Path class app.services.RestApi as it is an interface

If I override my Application class with getClasses() method and put valid resources without RC interface I get it working, however if I do not do that, then automatic scan picks up RC interface as well and I get previously mentioned exception.

Is there any way I can make a workaround for this Jersey limitation?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
OndroMihcommented, Jun 29, 2018

It seems that we hit a similar problem with our Payara Micro implementation. We needed to patch Jersey. Here’s the commit in Payara source code: https://github.com/payara/Payara/pull/2800/files#diff-1a0ff1b907622b750405cad68426242dR262 (the fix is in the patched Jersey version 2.27.payara-p5). The patched version of Jersey is here, but it’s bit of a mess: https://github.com/payara/Payara_PatchedProjects/pull/161/files

0reactions
OndroMihcommented, Jul 26, 2018

Let’s close this issue, @andymc12.

@Jamsek-m, feel free to discuss this on the Jersey mailing list or on Payara Forum

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to annotate JAX-RS on an interface while using Jersey
Use a ResourceConfig and do a registerClasses(MyImplementation. · Disable the package scanning configuration in web. · use a ResourceConfig and ...
Read more >
Developing a JAX-RS RESTful Service - dennis-xlc
A JAX-RS service is a Java class that uses JAX-RS annotations to bind and map specific incoming HTTP requests to Java methods that...
Read more >
JAX-RS - Annotation Inheritance - LogicBig
JAX -RS annotations may be used on the methods and method parameters of a super-class or an implemented interface.
Read more >
29.2 Creating a RESTful Root Resource Class
Request method designator annotations are runtime annotations, defined by JAX-RS, that correspond to the similarly named HTTP methods. Within a resource class ...
Read more >
Process JAX-RS annotations on interfaces #1427 - GitHub
In our project, we have jax-rs (jersey) interfaces and implementations. As the interfaces are shared, I do not want to put any annotation...
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