question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers

See original GitHub issue

Describe the bug Quarkus does not inject EntityManager given application.properties is created and 2 module dependencies are added in pom.xml

Expected behavior EntityManager is injected into controller to the field marked with @Inject

Actual behavior ./mvnw compile quarkus:dev result in error:

...
[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@Default]
...

To Reproduce Steps to reproduce the behavior:

  1. git clone git@github.com:4ntoine/NotesServerApp.git
  2. git checkout issue-5-quarkus-maven
  3. ./gradlew publishToMavenLocal
  4. cd app-quarkus
  5. ./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 Снимок экрана 2019-11-15 в 22 29 20

Environment (please complete the following information):

  • Output of uname -a or ver:

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.0.CR1

Additional context I’ve also tried to make it running with Gradle (https://github.com/quarkusio/quarkus/issues/5488).

Also i’ve tried to generate a project with code.quarkus.io and modify it to inject EntityManager and i have the same issue (attaching zip file with modified project files). code-with-quarkus.zip

So it makes me think smth is wrong and i’m not sure if it’s me who configured it incorrectly or it’s indeed some bug in Quarkus. Let me know if i can help with anything or please point on how to configure it the right way.

PS. I can see in the log:

22:37:57,565 INFO [org.hib.jpa.boo.int.PersistenceXmlParser] HHH000318: Could not find any META-INF/persistence.xml file in the classpath

But i guess it’s ok (as we intentionally follow the way without it).

Also i’d like to note that there are no db entities (marked with @Entity classes) in the source code, but i think it should not prevent EntityManager from being instantiated and injected, but just no entities tracked by EntityManager.

Here is run log for code-with-quarkus app:

~/Downloads/code-with-quarkus asmirnov$./mvnw compile quarkus:dev
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< org.acme:code-with-quarkus >---------------------
[INFO] Building code-with-quarkus 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ code-with-quarkus ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ code-with-quarkus ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- kotlin-maven-plugin:1.3.21:compile (compile) @ code-with-quarkus ---
[INFO] Applied plugin: 'all-open'
[INFO] 
[INFO] --- quarkus-maven-plugin:1.0.0.CR1:dev (default-cli) @ code-with-quarkus ---
Listening for transport dt_socket at address: 5005
22:37:56,774 INFO  [io.qua.dep.QuarkusAugmentor] Beginning quarkus augmentation
22:37:57,281 INFO  [org.jbo.threads] JBoss Threads version 3.0.0.Final
22:37:57,565 INFO  [org.hib.jpa.boo.int.PersistenceXmlParser] HHH000318: Could not find any META-INF/persistence.xml file in the classpath
22:37:57,736 INFO  [org.hib.Version] HHH000412: Hibernate Core {5.4.8.Final}
22:37:57,935 ERROR [io.qua.dev.DevModeMain] Failed to start Quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@Default]
	- java member: org.acme.ExampleResource#entityManager
	- declared on CLASS bean [types=[org.acme.ExampleResource], qualifiers=[@Default, @Any], target=org.acme.ExampleResource]
	at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:850)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:220)
	at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:106)
	at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:251)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
	at java.lang.Thread.run(Thread.java:745)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@Default]
	- java member: org.acme.ExampleResource#entityManager
	- declared on CLASS bean [types=[org.acme.ExampleResource], qualifiers=[@Default, @Any], target=org.acme.ExampleResource]
	at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:472)
	at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:404)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:212)
	... 14 more

	at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:157)
	at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:177)
	at io.quarkus.dev.DevModeMain.start(DevModeMain.java:95)
	at io.quarkus.dev.DevModeMain.main(DevModeMain.java:66)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@Default]
	- java member: org.acme.ExampleResource#entityManager
	- declared on CLASS bean [types=[org.acme.ExampleResource], qualifiers=[@Default, @Any], target=org.acme.ExampleResource]
	at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:850)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:220)
	at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:106)
	at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:251)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
	at java.lang.Thread.run(Thread.java:745)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@Default]
	- java member: org.acme.ExampleResource#entityManager
	- declared on CLASS bean [types=[org.acme.ExampleResource], qualifiers=[@Default, @Any], target=org.acme.ExampleResource]
	at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:472)
	at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:404)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:212)
	... 14 more

	at io.quarkus.builder.Execution.run(Execution.java:108)
	at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:121)
	at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:130)
	at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:111)
	... 3 more
Caused by: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@Default]
	- java member: org.acme.ExampleResource#entityManager
	- declared on CLASS bean [types=[org.acme.ExampleResource], qualifiers=[@Default, @Any], target=org.acme.ExampleResource]
	at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:850)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:220)
	at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:106)
	at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:251)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:941)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:415)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
	at java.lang.Thread.run(Thread.java:745)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@Default]
	- java member: org.acme.ExampleResource#entityManager
	- declared on CLASS bean [types=[org.acme.ExampleResource], qualifiers=[@Default, @Any], target=org.acme.ExampleResource]
	at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:472)
	at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:404)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:212)
	... 14 more

22:37:57,937 INFO  [io.qua.dev.DevModeMain] Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
gsmetcommented, Nov 15, 2019

It might be a stupid question but do you have at least one entity and are they properly detected?

They need to be indexed in Jandex.

1reaction
Sannecommented, Nov 15, 2019

hi @4ntoine

the META-INF/beans.xml resource shuld not be added to your main application but to each jar that you want Quarkus to “scan” for any additional components.

So in this case you need to add it to infra-gateway-jpa/src/main/resources/META-INF/beans.xml

I tested it locally, and works as expected so I’ll close this 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Unsatisfied dependencies for type EntityManager with ...
We normally inject EntityManager through '@PersistenceContext(unitname="name")' In order for you to use the constructor injection for the ...
Read more >
Unsatisfied dependency for EntityManager when creating a ...
From searching, I've found out this usually happens because a dependency is missing, there are no Entities or a configuration item is incorrect....
Read more >
WELD-001408: Unsatisfied dependencies for type - JBoss.org
WELD-001408 : Unsatisfied dependencies for type EntityManager with qualifiers · 19:01:17,349 ERROR [org.jboss.msc.service. · POiNT.ear".
Read more >
Injection Of Entitymanager - Apache TomEE
Creating the JPA Entity · Configure the EntityManager via a persistence.xml file · Injection via @PersistenceContext · MoviesTest.
Read more >
Missing DataSource in Quarkus - Lanky Dan Blog
UnsatisfiedResolutionException : Unsatisfied dependency for type javax.sql.DataSource and qualifiers [@Default] - java member: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found