EntityManager is not injected
See original GitHub issueDescribe 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (10 by maintainers)
Top Results From Across the Web
Why EntityManager is not injected? - java - Stack Overflow
Injection of EntityManagers only works in managed beans, since you are creating the Finder with new no container is involved.
Read more >JPA problem - EntityManager is not injected - Forums - IBM
I have made the Liberty JPA tutorial to work, but now I am rebuilding the app using injected JTA EntityManager instead of using...
Read more >EntityManager in not injected when using devmode with gradle
I'm using JPA + Hibernate without Panache. application.properties seems to be configured correctly. Beans injecting annotations are set. However ...
Read more >EntityManager is not injected inside a Jboss module
I'm working with jboss wildfly 9. I have a provider deployed as module into the modules directory. Then i have a jpa project...
Read more >Injection Of Entitymanager - Apache TomEE
This particular EntityManager is injected as an EXTENDED persistence context, which simply means that the EntityManager is created when the @Stateful bean is ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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: