playframework / playframework/play-samples

play-java-dagger2-example inject JPAApi

Open
#173 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
554
Forks
548
Avg merge
1d 11h
Merged PRs (30d)
57

Description

I am exploring the play-java-dagger2-example project. I tried to get JPAApi instance from MyComponentsFromContext like this:

JPAApi jpaApi = application().injector().instanceOf(JPAApi.class);

But this throws [NoSuchMethodException: play.db.jpa.JPAApi.<init>()]
What is the correct way to get JPAApi with Dagger 2?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the play-java-dagger2-example project and inspect MyComponentsFromContext, the Dagger 2 component setup, and the JPAApi injection path. Verify the approach against the shown application().injector().instanceOf(JPAApi.class) call; done means the example can obtain a JPAApi instance without the NoSuchMethodException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.