quarkus: EntityManager is not injected
Describe the bug
EntityManager
instance is not injected into @ApplicationScoped object so i’m having the following exception for ``:
...
12:02:31,107 ERROR [io.qua.dev.DevModeMain] Failed to start Quarkus: java.lang.ExceptionInInitializerError
...
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property entityManager has not been initialized
...
Expected behavior
EntityManager
instance is injected and ready -to-use, no exception are thrown
Actual behavior
during ./mvnw compile quarkus:dev
i have the following exception
...
12:02:31,107 ERROR [io.qua.dev.DevModeMain] Failed to start Quarkus: java.lang.ExceptionInInitializerError
...
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property entityManager has not been initialized
...
The app is shutdown.
To Reproduce Steps to reproduce the behavior:
- git clone git@github.com:4ntoine/NotesServerApp.git
- cd NotesServerApp
- git checkout 32c8240dfd6672471cdd73f613e092522fb6528e
- ./gradlew publishToMavenLocal
- cd app-quarkus
- ./mvnw compile quarkus:dev
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
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:
Additional context
- db entity is in transitive module (having META-INF/beans.xml)
- rest controllers are in transitive module (having META-INF/beans.xml)
- if commenting AddNoteController and ListNoteController i can run the app and
Hello1Controller
is available
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (10 by maintainers)
It turns out to be a problem with how CDI is being used in the supplied code:
If you use something like:
everything works as expected.
Note that you can simplify things even more by removing
QuarkusEntityManagerFactory
completely and using something like:So I’m going to go ahead and close this since it’s not a Quarkus bug. If you feel that this resolution is not correct, feel free to reopen and add more information.
Thanks
Thank you. Let me know if you need any assistance
пн, 18 нояб. 2019 г., 14:49 Georgios Andrianakis notifications@github.com: