quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

Unsatisfied dependency: no bean matches the injection point - keycloak #33956

Closed Paul6552 closed 1 month ago

Paul6552 commented 1 year ago

Describe the bug

I try to inject keycloak but then I get the error message: Unsatisfied dependency: no bean matches the injection point

I read the documentation from here: Documentation and checked my code so I have recognized some differences in documentation.

image

I thought setting the property quarkus.keycloak.admin-client.enabled to true would resolve my "unsatisfied dependency error" but when I tried to set the property in the application.properties file I get the message that the property "enabled" cannot be found: image

Is the property enabled still needed? And would this property anyhow resolve my problem with "unsatisfied dependency"?

My pom file if needed:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>at.tanzauswertung.portal</groupId>
        <artifactId>portal-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <groupId>at.tanzauswertung.portal-backend</groupId>
    <artifactId>portal-backend</artifactId>

    <properties>
        <webapp.dependency.phase>prepare-package</webapp.dependency.phase>
        <surefire-plugin.version>3.1.0</surefire-plugin.version>
        <lombok.version>1.18.26</lombok.version>
        <testcontainers.version>1.17.6</testcontainers.version>
        <quarkus.version>3.1.0.Final</quarkus.version>
        <version.apache-poi>5.2.3</version.apache-poi>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.quarkus.platform</groupId>
                <artifactId>quarkus-bom</artifactId>
                <version>${quarkus.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>at.tanzauswertung.api</groupId>
            <artifactId>pea-portal-api</artifactId>
            <version>1.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>6.20.5</version>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.lucene</groupId>
                    <artifactId>lucene-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>lucene-analyzers-common</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.lucene</groupId>
                    <artifactId>lucene-queryparser</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jfree</groupId>
                    <artifactId>jcommon</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jfree</groupId>
                    <artifactId>jfreechart</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jdt.core.compiler</groupId>
                    <artifactId>ecj</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.codehaus.castor</groupId>
                    <artifactId>castor-xml</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.olap4j</groupId>
                    <artifactId>olap4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.zxing</groupId>
                    <artifactId>core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.ibm.icu</groupId>
                    <artifactId>icu4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>postgresql</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.dasniko</groupId>
            <artifactId>testcontainers-keycloak</artifactId>
            <version>2.5.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>5.3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>${version.apache-poi}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>${version.apache-poi}</version>
        </dependency>
        <!-- Glaube braucht man nicht mehr
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>
        -->
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-arc</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-mailer</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-narayana-jta</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-hibernate-orm</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-hibernate-orm-panache</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-scheduler</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate.orm</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-agroal</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest-client-reactive</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest-client-reactive-jackson</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy-reactive</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy-reactive-jackson</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-jdbc-postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-undertow</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-keycloak-admin-client-reactive</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-keycloak-authorization</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-oidc</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-flyway</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-test-h2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5-mockito</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <configuration>
                    <skipTests>true</skipTests>
                    <systemProperties>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                    </systemProperties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/classes/META-INF/resources/portal
                            </outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.parent.basedir}/portal-webapp/build/</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>skipFrontendBuild</id>
            <properties>
                <surefire-plugin.version>${surefire-plugin.version}</surefire-plugin.version>
                <webapp.dependency.phase>none</webapp.dependency.phase>
            </properties>
        </profile>
    </profiles>

</project>

Expected behavior

keycloak bean can be injected

Actual behavior

keycloak bean cannot be injected

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

17

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

maven 3.9.2

Additional information

quarkus 3.1.0.Final

quarkus-bot[bot] commented 1 year ago

/cc @Ladicek (arc), @manovotn (arc), @mkouba (arc), @pedroigor (keycloak), @sberyozkin (keycloak)

sberyozkin commented 1 year ago

@Paul6552 quarkus.keycloak.admin-client.enabled is here: https://github.com/quarkusio/quarkus/blob/main/extensions/keycloak-admin-client-common/deployment/src/main/java/io/quarkus/keycloak/admin/client/common/KeycloakAdminClientBuildTimeConfig.java.

<dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-keycloak-admin-client-reactive</artifactId>
        </dependency>

depends on

<dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-keycloak-admin-client-common</artifactId>
        </dependency>

which is where this property is coming from.

Can you create a reproducer please ?

Paul6552 commented 1 year ago

@sberyozkin Does your answer mean that I have to import the dependency:

<dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-keycloak-admin-client-common</artifactId>
        </dependency>

as well? Because in the documentation there is no information about admin-client-common.

Please find the java file KeycloakService.java. There is the Keycloak injection with the unsatisfied dependency. image

Paul6552 commented 1 year ago

I am really sorry! I uploaded the wrong branch X)

This is the correct branch / project: Correct project

sberyozkin commented 1 year ago

@Paul6552 quarkus-keycloak-admin-client-common is in the dependency tree of keycloak-admin-client so it should be loaded without you having to manually include it.

Paul6552 commented 1 year ago

@sberyozkin Have you had time to take a closer look at the problem? Thanks

gsmet commented 1 month ago

I wanted to have a look at this old issue but the reproducer expired (which is definitely our fault, sorry about that).

I can see the properties mentioned above in the configuration properties we support so I don't know exactly what's going on. Given we didn't have other reports, it's probably specific to what you were doing and it's going to be hard to figure it out without a reproducer.

I'm going to close this issue. If you encounter it, open a new issue and attach a reproducer either as a GitHub repo or you can attach a zip file to the issue itself in GitHub.

sberyozkin commented 1 month ago

Sorry I've missed this one, but indeed, it would be good to have an uptodate reproducer should the problem persist