Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@Default] by extensions: quarkus-hibernate-orm + quarkus-jdbc-mssql + quarkus-undertow #7280

Closed
waldimiro opened this issue Feb 19, 2020 · 6 comments
Labels
area/hibernate-orm Hibernate ORM triage/invalid This doesn't seem right

Comments

@waldimiro
Copy link

Describe the bug
By add quarkus-hibernate-orm + quarkus-jdbc-mssql + quarkus-undertow extensions, I can't start the application due to: Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@default].

Expected behavior
EntityManager must be crerated.

Actual behavior
Quarkus doesn't starts.

To Reproduce
Steps to reproduce the behavior:

  1. From https://code.quarkus.io/ create a new project with quarkus-hibernate-orm + quarkus-jdbc-mssql + quarkus-undertow.
  2. In generated class ExampleResource add:
    @Inject EntityManager entityManager;
  3. Launch with quarkus:dev

Configuration

quarkus.transaction-manager.default-transaction-timeout=900
quarkus.datasource.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
quarkus.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=mydb
quarkus.datasource.username=sa
quarkus.datasource.password=pwd
quarkus.datasource.max-size=10
quarkus.datasource.min-size=5
quarkus.datasource.initial-size=5
quarkus.hibernate-orm.dialect=org.hibernate.dialect.SQLServer2012Dialect
quarkus.hibernate-orm.database.generation=none
quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.sql-load-script=no-file

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • openjdk-11.0.3.7-1
  • Quarkus 1.2.0.FInal
  • MSSQLExpress (SQL Server 14.0.1000)

Additional context
(Add any other context about the problem here.)

@waldimiro waldimiro added the kind/bug Something isn't working label Feb 19, 2020
@gastaldi gastaldi added the area/hibernate-orm Hibernate ORM label Feb 19, 2020
@gastaldi
Copy link
Contributor

@waldimiro does any stacktrace appear before that error? I have a project using H2 DB and it works fine

@waldimiro
Copy link
Author

@gastaldi with clean quarkus:dev

"C:\Program Files\Java\java-11-openjdk-11.0.3.7-1\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:64446,suspend=y,server=n -Dmaven.multiModuleProjectDirectory=C:\development\code-with-quarkus "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.2\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.2\plugins\maven\lib\maven-event-listener.jar" -javaagent:C:\Users\taarowa1.IntelliJIdea2019.3\system\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.2\lib\idea_rt.jar" org.codehaus.classworlds.Launcher -Didea.version2019.3.3 clean quarkus:dev
Connected to the target VM, address: '127.0.0.1:64446', transport: 'socket'
[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-clean-plugin:2.5:clean (default-clean) @ code-with-quarkus ---
[INFO] Deleting C:\development\code-with-quarkus\target
[INFO]
[INFO] --- quarkus-maven-plugin:1.2.0.Final:dev (default-cli) @ code-with-quarkus ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\development\code-with-quarkus\target\classes
Listening for transport dt_socket at address: 5005
14:01:52,116 INFO [org.jbo.threads] JBoss Threads version 3.0.0.Final
14:01:52,461 INFO [org.hib.jpa.boo.int.PersistenceXmlParser] HHH000318: Could not find any META-INF/persistence.xml file in the classpath
14:01:52,543 INFO [org.hib.Version] HHH000412: Hibernate Core {5.4.10.Final}
14:01:52,691 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, java.lang.Object], qualifiers=[@default, @Any], target=org.acme.ExampleResource]
at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:879)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:231)
at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:117)
at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:272)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:915)
at io.quarkus.builder.BuildContext.run(BuildContext.java:279)
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.base/java.lang.Thread.run(Thread.java:834)
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, java.lang.Object], 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:416)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:223)
... 14 more

at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:181)
at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:178)
at io.quarkus.dev.DevModeMain.start(DevModeMain.java:96)
at io.quarkus.dev.DevModeMain.main(DevModeMain.java:67)

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, java.lang.Object], qualifiers=[@default, @Any], target=org.acme.ExampleResource]
at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:879)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:231)
at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:117)
at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:272)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:915)
at io.quarkus.builder.BuildContext.run(BuildContext.java:279)
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.base/java.lang.Thread.run(Thread.java:834)
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, java.lang.Object], 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:416)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:223)
... 14 more

at io.quarkus.builder.Execution.run(Execution.java:108)
at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:128)
at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:114)
... 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, java.lang.Object], qualifiers=[@default, @Any], target=org.acme.ExampleResource]
at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:879)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:231)
at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:117)
at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:272)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:915)
at io.quarkus.builder.BuildContext.run(BuildContext.java:279)
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.base/java.lang.Thread.run(Thread.java:834)
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, java.lang.Object], 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:416)
at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:223)
... 14 more

14:01:52,692 INFO [io.qua.dev.DevModeMain] Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure
14:01:52,702 ERROR [io.qua.dev.DevModeMain] Failed to start quarkus: java.lang.IllegalArgumentException: workerPoolSize must be > 0
at io.vertx.core.VertxOptions.setWorkerPoolSize(VertxOptions.java:275)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder.convertToVertxOptions(VertxCoreRecorder.java:152)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder.initializeWeb(VertxCoreRecorder.java:105)
at io.quarkus.vertx.http.runtime.VertxHttpRecorder.startServerAfterFailedStart(VertxHttpRecorder.java:119)
at io.quarkus.vertx.http.deployment.devmode.VertxHotReplacementSetup.handleFailedInitialStart(VertxHotReplacementSetup.java:30)
at io.quarkus.dev.RuntimeUpdatesProcessor.startupFailed(RuntimeUpdatesProcessor.java:452)
at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:192)
at io.quarkus.dev.DevModeMain.start(DevModeMain.java:96)
at io.quarkus.dev.DevModeMain.main(DevModeMain.java:67)

@gastaldi
Copy link
Contributor

Ah yes, you must have an @Entity class in your project to use JPA.

@gastaldi
Copy link
Contributor

gastaldi commented Feb 19, 2020

Try creating a class like this in your project:

package org.acme;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Cake {

    @Id
    Long id;
}

@gastaldi
Copy link
Contributor

There is an issue (#7148) asking the possibility to inject an EntityManager without any entities

@waldimiro
Copy link
Author

@gastaldi With the "Cake" it works ;) thanks!!

@gastaldi gastaldi added triage/invalid This doesn't seem right and removed kind/bug Something isn't working labels Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants