Comments (16)
@geoand nvm, I have found the solution on #34180
I was using AdditionalBeanBuildItem instead of AdditionalIndexedClassesBuildItem. It is working now that I have changed.
Thanks!
from quarkus.
/cc @cescoffier (rest-client), @geoand (rest-client)
from quarkus.
I'm pretty sure we've discussed this in the past...
from quarkus.
@Ladicek probably knows the outcome of that discussion (because he has a great memory)
from quarkus.
The jax.rs specification says that the annotations are inherited (section 3.6) which is why it was very confusing to find that these are not:
https://download.oracle.com/otn-pub/jcp/jaxrs-2_0_rev_A-mrel-eval-spec/jsr339-jaxrs-2.0-final-spec.pdf?AuthParam=1710314633_0852fc20bcf0438b26aa009ada61dc73
from quarkus.
I don't think we discussed this particular situation, or at least I don't remember it (and my memory is not as good as Clement might think...), and the MP RestClient specification doesn't mention annotation inheritance at all.
It seems natural to fall back on the JAX-RS rules for annotation inheritance, which RestClient Reactive seems to do: https://github.com/quarkusio/quarkus/blob/3.7.2/extensions/resteasy-reactive/rest-client-reactive/deployment/src/main/java/io/quarkus/rest/client/reactive/deployment/RestClientReactiveProcessor.java#L433
Technically, the code example in the description of this issue doesn't follow the JAX-RS rules for annotation inheritance, because
Note that inheritance of class or interface annotations is not supported.
which means that the @Path
annotation must be repeated on B
(which it isn't), but that doesn't seem to be an issue here.
I'll try to reproduce and see.
from quarkus.
I can't reproduce. This seems to work both on Quarkus 3.7.2 and on current 999-SNAPSHOT.
from quarkus.
Ok, my apologies - the scenario as described in my original report DOES indeed work. However...
Additionally, I had a class C in the project, such that:
package org.acme.rest.client;
import org.eclipse.microprofile.rest.client.inject.RestClient;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
@ApplicationScoped
public class C {
@Inject
@RestClient
B bService;
public C() {
}
}
Running quarkus dev
results in:
2024-03-14 15:55:31,538 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: jakarta.enterprise.inject.spi.DeploymentException: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.acme.rest.client.B and qualifiers [@RestClient]
- injection target: org.acme.rest.client.C#bService
- declared on CLASS bean [types=[org.acme.rest.client.C, java.lang.Object], qualifiers=[@Default, @Any], target=org.acme.rest.client.C]
This does not happen if you modify the injection in C (of B) with the superclass A (with added @RegisterRestClient
)
Sorry for the confusion.
from quarkus.
When I was trying to reproduce, I of course tried to inject the sub-interface into a class. It worked flawlessly.
from quarkus.
ok - I understand what is happening with this issue example on my system. I can repeat the failure in a case I have, but the project structure is a bit different. Should I close this and reopen in another issue or provide complete example here?
from quarkus.
Feel free to continue in this issue.
from quarkus.
In my real code where I encountered this problem, I have multiple maven projects. You can refactor the example above in a similar way. Create a new quarkus project using:
quarkus create app org.acme:Foo
Move the superclass A.java and Extension.java into this new project, and add a dependency in the original rest-client-reactive-quickstart project to this, like:
<dependency>
<groupId>org.acme</groupId>
<artifactId>Foo</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
Build the project Foo, then run the rest-client-reactive-quickstart project with quarkus dev. You should then see:
2024-03-15 10:06:59,141 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: jakarta.enterprise.inject.spi.DeploymentException: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.acme.rest.client.B and qualifiers [@RestClient]
- injection target: org.acme.rest.client.C#bService
- declared on CLASS bean [types=[org.acme.rest.client.C, java.lang.Object], qualifiers=[@Default, @Any], target=org.acme.rest.client.C]
from quarkus.
I'm facing a similar issue.
I have a RestClient:
package com.test;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
@Path("/api/v2")
@RegisterRestClient
@ApplicationScoped
public interface TestClient {
@GET
@Path("/test")
Response test();
}
And I'm trying to inject this Rest Client:
package com.test;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.eclipse.microprofile.rest.client.inject.RestClient;
@ApplicationScoped
public class TestBean {
@Inject
@RestClient
TestClient client;
}
but I'm getting this error:
Caused by: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type com.test.TestClient and qualifiers [@RestClient]
- injection target: com.test.TestBean#client
- declared on CLASS bean [types=[com.test.TestBean, java.lang.Object], qualifiers=[@Default, @Any], target=com.test.TestBean]
at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:519)
at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:638)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:308)
This only happens if I update from quarkus-resteasy-client and quarkus-resteasy-client-deployment to quarkus-rest-client and quarkus-rest-client-deployment
from quarkus.
Does the problem above persist if you remove @ApplicationScoped
?
from quarkus.
@geoand yes, I have tried that, it fails with same error. It only works if I use resteasy-client instead of rest-client. However, as this is an extension, I cannot use resteasy as it conflicts with the new "rest" from Quarkus 3.9 when I add this extension to a Quarkus 3.9 project:
Multiple producers of item class io.quarkus.security.spi.DefaultSecurityCheckBuildItem (io.quarkus.resteasy.reactive.common.deployment.ResteasyReactiveCommonProcessor#setUpDenyAllJaxRs)
from quarkus.
That's very weird. Please attach a sample application that exhibits this behavior so we can check.
from quarkus.
Related Issues (20)
- Better exception when accessing two non-XA datasources in a transaction HOT 29
- @EndpointDisabled can be used on methods HOT 9
- Quarkus 3.10 fails to start if some OIDC providers don't support UserInfo HOT 4
- No database found to handle jdbc:postgresql://.... HOT 4
- Potential NPE thrown from QuarkusClassLoader.getResources HOT 4
- smallrye-reactive-messaging-kafka: Emitter inject in SubscriberDecorator unable to connect emitter error HOT 4
- Build-time configuration values for quarkus.application.name are ignored HOT 2
- gRPC Dev UI bug in 3.10.0 HOT 2
- Quarkus REST should check for `@CustomSerialization` annotations on resource methods returning `Multi` HOT 1
- OpenAPI auto-add-tags feature can't work with interface and some quarkus.rest.path processing errors. HOT 1
- quarkus disposal method called in wrong order
- codestart are using legacy properties still HOT 3
- Application thinks quarkus.http.host is set to 0.0.0.0 in dev mode but it's set to localhost HOT 2
- Update ubi8/openjdk-VERSION from 1.18 to 1.19
- quarkus-oidc ignores jvm proxy configuration and clashes with oidc-client when both proxies are set HOT 8
- Add filtering to dev-ui (with local-storage memory) HOT 1
- OIDC: injecting a `UserInfo` breaks startup HOT 11
- Cannot mock `EntityManager` methods with `@InjectMock Session`
- add property to configure allowed devui origins HOT 5
- code.quarkus.io templates not updated to new config changes HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quarkus.