EntityManager in not injected when using devmode with gradle
See original GitHub issueDescribe the bug
I’m using JPA + Hibernate without Panache. application.properties seems to be configured correctly. Beans injecting annotations are set. However EntityManager
instance is not injected.
Expected behavior
EntityManager
instance is instantiated by Quarkus (Arc) and injected.
Actual behavior
EntityManager
instance is null
.
To Reproduce Steps to reproduce the behavior:
- git clone git@github.com:4ntoine/NotesServerApp.git
- git checkout issue-5-quarkus
- ./gradlew :app-quarkus:quarkusDev
- navigate to “localhost:8080/hello” and make sure you can see stacktrace NPE’’
Configuration
quarkus.datasource.url = jdbc:h2:mem:notes
quarkus.datasource.driver = org.h2.Driver
# drop and create the database at startup (use `update` to only update the schema)
quarkus.hibernate-orm.database.generation=drop-and-create
Screenshots
(If applicable, add screenshots to help explain your problem.)
Environment (please complete the following information):
- Output of
uname -a
orver
:
Darwin MBP-Anton.local 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64
- Output of
java -version
:
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
- GraalVM version (if different from Java):
- Quarkus version or git rev:
1.0.0CR1
Additional context CDI configuration:
package name.antonsmirnov.notes
import name.antonsmirnov.notes.gateway.JpaGateway
import name.antonsmirnov.notes.gateway.mapper.MapperImpl
import name.antonsmirnov.notes.usecase.*
import javax.enterprise.inject.Produces
import javax.inject.Inject
import javax.persistence.EntityManager
class QuarkusEntityManagerFactory {
@Inject
lateinit var entityManager: EntityManager // will be injected by Quarkus (but is not!)
}
class Configuration {
val mapper = MapperImpl()
val gateway = JpaGateway(QuarkusEntityManagerFactory().entityManager, mapper)
val addNote: AddNote = AddNoteImpl(gateway)
val listNotes: ListNotes = ListNotesImpl(gateway)
@Produces
fun getAddNoteUseCase(): AddNote = addNote
@Produces
fun getListNotesUseCase(): ListNotes = listNotes
}
dependencies configuration (Gradle + Kotlin DSL):
...
dependencies {
implementation(project(":app-impl"))
implementation(project(":infra-gateway-jpa"))
implementation(project(":infra-rest-jax-rs")) {
// provided by Quarkus or it's transitive dependencies
exclude("javax.ws.rs:javax.ws.rs-api:2.0")
exclude("javax.enterprise:cdi-api:2.0.SP1")
}
implementation("io.quarkus:quarkus-kotlin")
implementation("io.quarkus:quarkus-resteasy-jsonb")
implementation("io.quarkus:quarkus-jdbc-h2")
implementation("io.quarkus:quarkus-hibernate-orm")
implementation(enforcedPlatform("io.quarkus:quarkus-bom:1.0.0.CR1"))
implementation("io.quarkus:quarkus-resteasy")
}
...
Does it look like correct CDI configuration? Should entityManager
be injected by Quarkus before it’s entityManager
accessed?
Issue Analytics
- State:
- Created 4 years ago
- Comments:25 (23 by maintainers)
Here it is, I hope it’s good enough to work with.: https://gitlab.informatik.uni-bremen.de/tobias5/aut0m4t0n
I am taking up this issue. If its fine