title: CDI with Non Quarkus Spring Jars
body: <p>We are trying to migrate our application from Spring to Quarkus Spring. We are Ok to re-write our application logic as Required.
  Problem comes as we are using shared spring jars which are legacy and there are many in numbers. Most spring jars are using Dependency Injection using @Autowired, but corresponding class that is getting injected does not have @Component Annotations.</p>
  <p>Will describe problem with example:</p>
  <blockquote>
  <p>Class &quot;MyProject&quot; belong to Quarkus Applicatioin</p>
  </blockquote>
  <pre><code>public class MyProject {
      
      @Autowired
      private OtherLevelOne otherLevelOne;
  
      public void invokeMe() {
          this.otherLevelOne.call();
      }
  }
  </code></pre>
  <blockquote>
  <p>Class OtherLevelOne and OtherLevelTwo belongs to a dependency spring jar.</p>
  </blockquote>
  <pre><code>public class OtherLevelOne {
      
      @Autowired
      private OtherLevelTwo otherLevelTwo;
  
      
  
  public void call() {
          this.otherLevelTwo.otherCall();
      }
  }
  
  public class OtherLevelTwo {
      
      public void otherCall() {
          
      }
  }
  </code></pre>
  <blockquote>
  <p>Issue Faced.</p>
  </blockquote>
  <pre><code>During compilation of Quakrus Application we get error:
  </code></pre>
  <pre><code>[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.1.3.Final:build (quarkus-app-build) on project service-quarkus: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
  [ERROR]     [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: Found 2 deployment problems:
  [ERROR] [1] Unsatisfied dependency for type OtherLevelOne and qualifiers [@Default]
  </code></pre>
  <blockquote>
  <p>Things Tried: Added a Producer class for Both OtherLevelOne and OtherLevelTwo. This helped in resolving the Compile time Unsatisfied dependency issue and Build was success. But now we faced a NullPointException as runtime when method &quot;call&quot; of OtherLevelOne tried to access the instance of &quot;OtherLevelTwo&quot;. So Looks like second level injection did not happen. Possibly Quarkus does not support this (without some modifications like adding beans.xml and @Component annotations to all the classes in dependency jars).</p>
  </blockquote>
  <pre><code>@Dependent
  public class ProducerClass {
  
      @Produces
      public OtherLevelOne createOtherLevelOne() {
          return new OtherLevelOne();
      }
  
      @Produces
      public OtherLevelTwo createOtherLevelTwo(){
          return new OtherLevelTwo();
      }
  }
  </code></pre>
  <blockquote>
  <p><strong>Question</strong></p>
  </blockquote>
  <ol>
  <li>Is there a way we can make Quarkus work in this scenario without compiling all the dependencies with Quarkus?</li>
  <li>Is it possible to write a Quarkus extenstion that can help in achieving Dependency Injection of required Types?</li>
  </ol>
  <p>Thanks.</p>