fatherazrael
fatherazrael

Reputation: 5957

Problem with Quarkus Dependency Injection to JPA Entity Manager

Problem with the build

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: Found 2 deployment problems: 
[1] Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@DataSource(value = "ergoint")]
    - java member: com.int.dao.EPersistence#entityManagerE
    - declared on CLASS bean [types=[java.lang.Object, com.int.dao.EPersistence], qualifiers=[@Default, @Any], target=com.int.dao.EPersistence]
[2] Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers [@DataSource(value = "madata")]
    - java member: com.int.dao.MPersistence#entityManagerM
    - declared on CLASS bean [types=[com.int.dao.MasterDataPersistence, java.lang.Object], qualifiers=[@Default, @Any], target=com.int.dao.MPersistence]
    at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:873)

Code:

@ApplicationScoped
public class MPersistence {

    @Inject
    @DataSource("madata")
    private EntityManager entityManagerMaster;

Properties file:

quarkus.datasource.driver=oracle.jdbc.driver.OracleDriver
quarkus.hibernate-orm.dialect=oracle.jdbc.driver.OracleDriver

quarkus.datasource.madata.url=jdbc:oracle:thin:@myhost:1521:orcl
quarkus.datasource.madata.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.madata.username=quarkus_test
quarkus.datasource.madata.password=quarkus_test

Simply run "maven clean install" from eclipse ide and get this issue while running test case.

(Earlier i think these two classes were readable with @Stateless from EJB but when i update quarkus to 1.1.0 final it removed all EJB dependencies. So i put application scoped)

Upvotes: 2

Views: 7496

Answers (1)

Guillaume Smet
Guillaume Smet

Reputation: 10519

Update: since Quarkus 1.8, we support setting up several persistence units directly in the application.properties. See https://quarkus.io/guides/hibernate-orm#multiple-persistence-units for more information.

We do not support multiple persistence units configured in the application.properties yet. Thus the EntityManagers you try to inject are not created by Quarkus.

You can track this issue https://github.com/quarkusio/quarkus/issues/2835 to be notified of our progress on the subject .

Upvotes: 2

Related Questions