I'm trying to manage a class through CDI called MongoQuery, which contains logic for querying MongoDB. This will need information from caches being managed through ArC CDI (Quarkus flavor CDI implementation for substrateVM). I can create it manually in my ListingResource class (see commented out code in said class for how I was doing it), but not when I set it to be managed in the request scope.
The items all individually work, its when I put it all together that it falls apart and complains that there are unresolved dependencies. I've included a stack trace that I get when attempting to build, as well as some relevant code snippets of the classes that are causing issues building.
What is causing the issues in CDI? The only thing I could think of that would cause this issue is type erasure causing issues when doing a lookup for relevant beans, but I have generics sprinkled through the code and haven't had issues up to this point.
Actual code has been pushed to a GitHub fork in the current state if anyone wishes to see full code.
org.eclipsefoundation.marketplace.resource.ListingResource
@Path("/listings")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@RequestScoped
public class ListingResource {
private static final Logger LOGGER = LoggerFactory.getLogger(ListingResource.class);
@Inject
MongoDao dao;
@Inject
CachingService<List<Listing>> cachingService;
@Inject
RequestWrapper params;
@Inject
DtoFilter<Listing> dtoFilter;
@Inject
MongoQuery<Listing> q;
/**
* Endpoint for /listing/ to retrieve all listings from the database along with
* the given query string parameters.
*
* @param listingId int version of the listing ID
* @return response for the browser
*/
@GET
public Response select() {
//MongoQuery<Listing> q = new MongoQuery<>(params, dtoFilter);
...
org.eclipsefoundation.marketplace.model.MongoQuery
@RequestScoped
public class MongoQuery<T> {
private static final Logger LOGGER = LoggerFactory.getLogger(MongoQuery.class);
@Inject
RequestWrapper wrapper;
@Inject
DtoFilter<T> dtoFilter;
private Bson filter;
private Bson sort;
// flag that indicates that aggregate should be used as filter
private boolean useAggregate = false;
...
Stacktrace:
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.eclipsefoundation.marketplace.model.MongoQuery<org.eclipsefoundation.marketplace.dto.Listing> and qualifiers [@Default]
- java member: org.eclipsefoundation.marketplace.resource.ListingResource#q
- declared on CLASS bean [types=[org.eclipsefoundation.marketplace.resource.ListingResource, java.lang.Object], qualifiers=[@Default, @Any], target=org.eclipsefoundation.marketplace.resource.ListingResource]
at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:835)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:214)
at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:106)
at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:768)
at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)```