title: Java & AWS & Dependency Injection (DI) - cannot find symbol DaggerAppComponent
body: <p>I want to implement DI in my application, but after I did this I have issues with CRUD methods.</p>
  
  <p>I've created interface:</p>
  
  <pre><code>@Singleton
  @Component(modules = {AppModule.class, DbModule.class, AuthGatewayModule.class})
  public interface AppComponent {
  Context getContext();
  GymService getGymService();
  KitchenService getKitchenService();
  ActivitiesService getActivitiesService();
  AuthGateway getAuthGateway();
  LandingService getLandingService();
  Logger getLogger();
  
  void inject(Logger logger);
  }
  </code></pre>
  
  <p>This is appModule:</p>
  
  <pre><code>@Module
  public class AppModule {
  private final Context context;
  
  
  public AppModule(Context context) {
      this.context = context;
  }
  
  @Provides
  @Singleton
  public Context provideContext() {
      return context;
  }
  
  @Provides
  @Singleton
  public Logger logger() {
      return new Logger(context);
  }
  }
  </code></pre>
  
  <p>And dbModule:</p>
  
  <pre><code>@Module
  public class DbModule {
  @Provides
  public DbService provideDbService(Logger logger) {
      return new DatabaseController(Regions.EU_CENTRAL_1, logger);
  }
  }
  </code></pre>
  
  <p>This is my KitchenService class with one example method:</p>
  
  <pre><code>public class KitchenService {
  
  private DatabaseController databaseController;
  private LambdaLogger logger;
  
  @Inject
  public KitchenService(){}
  
  public KitchenService(DatabaseController databaseController, LambdaLogger logger) {
      this.databaseController = databaseController;
      this.logger = logger;
  }
  
  //PRODUCT CRUD METHODS
  public Product addProduct(Product product) {
  
      databaseController.save(product);
      logger.log("Product created");
  
      return product;
  
  }
  </code></pre>
  
  <p>I wanted to add some product to DB, that worked fine before I implemented DI, but now I have java.lang.NullPointerException.</p>
  
  <p>And this is AddProductLambda class:</p>
  
  <pre><code>public class AddProductLambda extends Lambda {
  @Override
  public ApiGatewayResponse handleRequest(Map&lt;String, Object&gt; input, Context context) {
      super.handleRequest(input, context);
      try {
          Product product = RequestUtil.parseRequestBody(input, Product.class);
          KitchenService kitchenService = appComponent.getKitchenService();
          Product addedProduct = kitchenService.addProduct(product);
          return ResponseUtil.generateResponse(HttpStatus.SC_CREATED, addedProduct);
      } catch (IllegalArgumentException e) {
          return ResponseUtil.generateResponse(HttpStatus.SC_BAD_REQUEST, e.getMessage());
  
      }
  
  }
  }
  </code></pre>
  
  <p>And Lambda that AddProductLambda extends:</p>
  
  <pre><code>public abstract class Lambda implements RequestHandler&lt;Map&lt;String, Object&gt;, ApiGatewayResponse&gt; {
  protected Logger logger;
  protected AppComponent appComponent;
  
  @Override
  public ApiGatewayResponse handleRequest(Map&lt;String, Object&gt; input, Context context) {
      appComponent = DaggerAppComponent.builder().appModule(new AppModule(context)).build();
  
      logger = new Logger(context);
  
      // Inject logger
      appComponent.inject(logger);
  
      logger.log(input.toString());
  
      return null;
  }
  }
  </code></pre>
  
  <p>I did something wrong? Can someone help me with this problem?</p>