'Unsatisfied dependency exception' when injecting CDI bean from another project in Quarkus

Solution Verified - Updated -

Issue

  • When attempting to inject a CDI bean from Project A into Project B in a Quarkus application, the following error occurs during the build process:

    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 test.xml.filereader and qualifiers [@Default] - java member: 
    org.acme.hibernate.orm.XmlResource#fileReader - declared on CLASS bean [types=. 
    [org.acme.hibernate.orm.XmlResource, java.lang.Object], qualifiers=[@Default, @Any], 
    target=org.acme.hibernate.orm.XmlResource]
    

    Here is a example of project A:

    @Slf4j
    @ApplicationScoped
    public class FileReader {
    
        @Inject
        Configuration configuration;
    
        public void testCDIInject() {
        }
    
    }
    

    And Project B:

    @Path("/test")
    public class XmlResource {
    
      @Inject
      FileReader fileReader;
    
      @GET
      public String get() {
        fileReader.testCDIInject();
        return "asdf";
      }
    }
    

Project A is installed using the command mvn clean install -U, and it is included as a dependency in Project B’s pom.xml. Nevertheless, when building the application the Unsatisfied Dependency Exception arises.

Environment

  • Red Hat build of Quarkus
    • 3.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content